Skip to content

Instantly share code, notes, and snippets.

@edvakf edvakf/gist:8434738
Created Jan 15, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.