找回密码
 加入
搜索
查看: 1840|回复: 0

[AU3基础] 字符串 16进制 互相转换的问题 乱码了

[复制链接]
发表于 2011-9-13 19:01:03 | 显示全部楼层 |阅读模式
字符串 16进制 互相转换的问题
雪花
\uD1A9\uBBA8
??
e+>19:00:19 AutoIT
---------------------------
雪花
---------------------------
\uD1A9\uBBA8

톩뮨


---------------------------
确定   
---------------------------


#include<string.au3>
Func stringtoHex($Hex)
Local $b = ''
$Hex = StringRegExp($Hex,"(.?)",3)
For  $i = 0 To UBound($Hex) - 2
        $b &= "\u"& _StringToHex($Hex[$i])
Next
        Return $b 
EndFunc

Func Hextostring($string)
    Local $temp_str,$temp_s
    $temp_s=StringSplit($string,'\u',3)  
        $string=''        
    For $n=0 To UBound($temp_s)-1
        If StringLen($temp_s[$n])>4 Then
            $temp_s[$n]=ChrW('0x'&StringMid($temp_s[$n],1,4))&StringMid($temp_s[$n],5)
            $string&=$temp_s[$n]
        ElseIf StringLen($temp_s[$n])<4 Then
            $string&=$temp_s[$n]
        Else                
        $temp_s[$n]=ChrW('0x'&$temp_s[$n])
        $string&=$temp_s[$n]
        EndIf
    Next
    Return $string
EndFunc

ConsoleWrite(Hextostring("\u96EA\u82B1")&@CRLF)
ConsoleWrite(stringtoHex(Hextostring("\u96EA\u82B1"))&@CRLF)
ConsoleWrite(Hextostring(stringtoHex(Hextostring("\u96EA\u82B1")))&@CRLF)

MsgBox(0,Hextostring("\u96EA\u82B1"),stringtoHex(Hextostring("\u96EA\u82B1"))&@CRLF&Hextostring(stringtoHex(Hextostring("\u96EA\u82B1")))&@CRLF)

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 01:36 , Processed in 0.073316 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表