utf8's tag archives

ASP来实现UTF8转换GB2312国标码

ASP来实现UTF8转换GB2312国标码-GB2312转UTF-8'个人代码风格注释(变量名中第一个小写字母表表示变量类型) 'i:为Integer型; 's:为String; Function U2UTF8(Byval a_iNum)     Dim sResult,sUTF8     Dim iTemp,iHexNum,i    iHexNum = Trim(a_iNum)    If iHexNum = "" Then         Exit Function     End If    sResult = ""    If (iHexNum < 128) Then         sResult = sResult & iHexNum     ElseIf...

UTF-8 GBK下PHP获取字符串长度

UTF-8 GBK下PHP获取字符串长度,是langwan写的,贴过来大家分享,完美的解决了PHP下获取UTF-8或者GBK字符集的字符串长度问题!/** 统计字符串长度 *@author langwan *@param $str 被统计字符串*/function sstrlen($str) { global $charset; $n = 0; $p = 0; $c = ''; $len = strlen($str); if($charset == 'utf-8') { for($i = 0; $i < $len; $i++) { $c = ord($str{$i}); if($c > 252) { $p = 5; } elseif($c > 248) { $p = 4; }...

UTF8编码转Unicode

function Utf8ToUnicode(strUtf8) { var bstr = ""; var nTotalChars = strUtf8.length; // total chars to be processed. var nOffset = 0; // processing point on strUtf8 var nRemainingBytes = nTotalChars; // how many bytes left to be converted var nOutputPosition = 0; var iCode, iCode1, iCode2; // the value of the unicode.while (nOffset < nTotalChars) { iCode = strUtf8.charCodeAt(nOffset); if ((iCode &...