求ansi转usc2,也就是汉字转成\u6dd8\u5b9d\u7ecf\u9a8c\的格式
请高人给个ansi转usc2,也就是汉字转成\u6dd8\u5b9d\u7ecf\u9a8c\的格式的代码! Local $sCH = "中文常用内码扩展编码"MsgBox(0, "JSON", uniEncode($sCH))
MsgBox(0, "UTF-8", uniEncode($sCH, "&#x", ";"))
MsgBox(0, "UNICODE", uniEncode($sCH, "&#", ";", 10))
MsgBox(0, "ASCII", uniEncode($sCH, "", "", 10))
MsgBox(0, "%", uniEncode($sCH, "%"))
Func uniEncode($sStr, $sHead = "\u", $sSplit = "", $iBase = 16)
Local $sUni = "", $iCode
Local $aSpl = StringSplit($sStr, "")
If Not @error Then
For $i = 1 To $aSpl
If StringRegExp($aSpl[$i], "[^\x00-\xff]") Then
$iCode = AscW($aSpl[$i])
If $iBase = 16 Then $iCode = Hex($iCode, 4)
$sUni &= StringLower($sHead & $iCode & $sSplit)
Else
$sUni &= $aSpl[$i]
EndIf
Next
EndIf
Return $sUni
EndFunc ;==>uniEncode http://www.autoitx.com/thread-38364-1-1.html 谢谢!非常感谢!
页:
[1]