Created
January 15, 2014 11:39
-
-
Save edvakf/8434738 to your computer and use it in GitHub Desktop.
PHP5.5で想定通りに動かなくなったコード
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
/** | |
* 想定する文字列(UCS2)かどうか | |
* (parse_strした結果に適用される) | |
*/ | |
private static function isValidString($str) | |
{ | |
if (mb_strlen($str, 'UTF-8') > self::MAX_DETAIL_CHAR_LENGTH) { | |
return false; | |
} | |
$ucs2 = mb_convert_encoding($str, 'UCS-2', 'UTF-8'); | |
$utf8 = mb_convert_encoding($ucs2, 'UTF-8', 'UCS-2'); | |
if ($str !== $utf8) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment