Skip to content

Instantly share code, notes, and snippets.

@girvan
Created March 22, 2012 03:11
Show Gist options
  • Save girvan/2155369 to your computer and use it in GitHub Desktop.
Save girvan/2155369 to your computer and use it in GitHub Desktop.
function big52utf8($big5str) {
$blen = strlen($big5str);
$utf8str = "";
for($i=0; $i<$blen; $i++) {
$sbit = ord(substr($big5str, $i, 1));
//echo $sbit;
//echo "<br>";
if ($sbit < 129) {
$utf8str.=substr($big5str,$i,1);
}elseif ($sbit > 128 && $sbit < 255) {
$new_word = iconv("big5", "UTF-8", substr($big5str,$i,2));
$utf8str.=($new_word=="")?" ":$new_word;
$i++;
}
}
return $utf8str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment