Given a block of text that\'s known to be Chinese and encoded in UTF-8, is there a way to determine if it\'s Simplified or Traditional?
I don't know if this will work, but I'd try using iconv to see if it will translate between the charsets correctly, comparing the results from the same conversion with //TRANSLIT and //IGNORE. If the two results match, then the charset conversion hasn't encountered any characters that fail to translate, so you should have a match.
$test1 = iconv("UTF-8", "big5//TRANSLIT", $text);
$test2 = iconv("UTF-8", "big5//IGNORE", $text);
if ($test1 == $test2) {
echo 'traditional';
} else {
$test3 = iconv("UTF-8", "gb2312//TRANSLIT", $text);
$test4 = iconv("UTF-8", "gb2312//IGNORE", $text);
if ($test3 == $test4) {
echo 'simplified';
} else {
echo 'Failed to match either traditional or simplified';
}
}