在线求中文转GB2312编码的urlencode函数
本帖最后由 sunafter 于 2009-9-13 00:19 编辑只搜到一个中文转UTF8的函数,但是要用到中文转GB2312编码的函数,本人比较菜,写不出来,求大侠告知!
比如http://www.baidu.com/s?wd=%C4%E3%BA%C3
就是百度搜索你好,我想要的函数就是一个能将“你好”转换成“%C4%E3%BA%C3”
感谢afan大侠的帮助,问题已经解决!:face (23): 急求啊,谢谢!!! 这是一个将中文转换成UTF8的函数,我想要转换成ANSI(gb2312)编码,求啊!Func _UnicodeURLEncode($UnicodeURL) ;==>_UnicodeURLEncode
Local $UnicodeBinaryLength,$UnicodeBinary,$UnicodeBinary2
$UnicodeBinary = StringToBinary ($UnicodeURL,4)
$UnicodeBinary2 = StringReplace($UnicodeBinary, '0x', '', 1)
$UnicodeBinaryLength = StringLen($UnicodeBinary2)
Local $EncodedString,$UnicodeBinaryChar,$EncodedString
For $i = 1 To $UnicodeBinaryLength Step 2
$UnicodeBinaryChar = StringMid($UnicodeBinary2, $i, 2)
If StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", BinaryToString ('0x' & $UnicodeBinaryChar,4)) Then
$EncodedString &= BinaryToString ('0x' & $UnicodeBinaryChar)
Else
$EncodedString &= '%' & $UnicodeBinaryChar
EndIf
Next
Return $EncodedString
EndFunc 非要函数吗?那我整一个试试 MsgBox(0, 0, cn2ansi('你好'))
Func cn2ansi($wchar)
Dim $kg = ''
For $i = 1 To StringLen($wchar)
$kg &= ' '
Next
Local $wz = StringToBinary($wchar & $kg), $anstr = '%'
For $ii = 3 To StringLen($wz) Step 2
$anstr &= BinaryToString(StringMid($wz, $ii, 2)) & '%'
Next
Return StringTrimRight($anstr, 1)
EndFunc ;==>cn2ansi
MsgBox(0, 0, cn2ansi('你好'))
Func cn2ansi($wchar)
Dim $kg = ''
For $i = 1 To StringLen($wchar)
$kg &= ' '
Next
Local $wz = StringToBinary($wchar & $kg), $anstr = '%'
For $ii = 3 To St ...
afan 发表于 2009-9-12 23:12 http://www.autoitx.com/images/common/back.gif
膜拜啊,感谢!!!! 本帖最后由 bing614 于 2009-9-13 03:15 编辑
此函数AU3已经有了。#include <INet.au3>
MsgBox(0, "",_INetExplorerCapable("中国人")) 此函数AU3已经有了。#include
MsgBox(0, "",_INetExplorerCapable("中国人"))
bing614 发表于 2009-9-13 03:12 http://www.autoitx.com/images/common/back.gif
结果不正确啊,少了一部分 #include <INet.au3>
MsgBox(0, "",_INetExplorerCapable("中国人"))
afan 发表于 2009-9-12 23:12 http://www.autoitx.com/images/common/back.gif
这为啥要搞个$kg,后面多了那么多空格?
页:
[1]