Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created January 15, 2014 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edvakf/8434738 to your computer and use it in GitHub Desktop.
Save edvakf/8434738 to your computer and use it in GitHub Desktop.
PHP5.5で想定通りに動かなくなったコード
/**
* 想定する文字列(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