Created
October 18, 2017 03:17
-
-
Save luhaoming/9672f182ab42edb6492ed5599c756f45 to your computer and use it in GitHub Desktop.
check the string contains big5 charactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withBig5($arg_strContent) | |
{ | |
$blnEnglishOnly= true; | |
$intLoopCount = 0; | |
$intContentLength = strlen($arg_strContent); | |
while ($intLoopCount < $intContentLength) | |
{ | |
$chrSingle = substr($arg_strContent,$intLoopCount,1); | |
if(ord($chrSingle) > 0x80) | |
{ | |
$chrSingle = substr($arg_strContent,$intLoopCount,2); | |
$intLoopCount++; | |
if(isBig5($chrSingle)) | |
{ | |
$blnEnglishOnly = false; | |
break; | |
} | |
} | |
$intLoopCount++; | |
} | |
return !$blnEnglishOnly; | |
} | |
function isBig5($char="") | |
{ | |
$bc = hexdec(bin2hex($char)); | |
if(($bc>=0xa440 && $bc<= 0xc67e)||($bc>=0xc940 && $bc<= 0xf9dc)) | |
{ | |
return true; | |
} | |
else | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment