Last active
January 18, 2016 09:52
-
-
Save satooshi/48fe74ebf76623ec2d0c to your computer and use it in GitHub Desktop.
Get NFC and NFD string of Vietnamese characters.
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
<?php | |
# http://www.unicode.org/charts/PDF/U1E00.pdf | |
$targets = [ | |
'aắằặấầẩậẳẵạàáâãảăẫ', | |
'eẽẹếềểễệèéêẻ', | |
'oốồổỗộờởơớỡòóôõỏọợ', | |
'iịìíĩỉ', | |
'uứừửưữựụùúũủ', | |
'yỳỷỹỵý' | |
]; | |
# http://php.net/manual/en/class.normalizer.php | |
foreach ($targets as $target) { | |
$str1 = Normalizer::normalize($target, Normalizer::FORM_D); | |
var_dump($str1); | |
$str2 = Normalizer::normalize($target, Normalizer::FORM_C); | |
var_dump($str2); | |
} | |
/* | |
string(72) "aắằặấầẩậẳẵạàáâãảăẫ" | |
string(47) "aắằặấầẩậẳẵạàáâãảăẫ" | |
string(44) "eẽẹếềểễệèéêẻ" | |
string(31) "eẽẹếềểễệèéêẻ" | |
string(72) "oốồổỗộờởơớỡòóôõỏọợ" | |
string(47) "oốồổỗộờởơớỡòóôõỏọợ" | |
string(16) "iịìíĩỉ" | |
string(13) "iịìíĩỉ" | |
string(44) "uứừửưữựụùúũủ" | |
string(30) "uứừửưữựụùúũủ" | |
string(16) "yỳỷỹỵý" | |
string(15) "yỳỷỹỵý" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment