Skip to content

PHP 한글 존재 여부 검사하기

MintState May 11, 2018 at 1:30 PM Views 8149

PHP 한글 존재 여부 검사하기

1. EUC-KR인 경우

if (preg_match("/[\xA1-\xFE][\xA1-\xFE]/", $str)) 
	echo "한글포함.";
else
	echo "한글없음";

2. UTF-8인 경우

if (preg_match("/[\xE0-\xFF][\x80-\xFF][\x80-\xFF]/", $str)) 
	echo "한글포함.";
else
	echo "한글없음";

euc-kr -> utf-8

$str = iconv("euckr", "utf8", $str);
Share X Facebook LINE QR code

0 comments

Be the first to comment.