回复 1# hanleicool
编码前的URl为 UTF8 编码,解码用的是 ANSI 解码,当然就乱码了。加个参数传递。$encode2 = "qvod%3A%2F%2F890800828%7CE0465DF8A6975D6533327B351A8B7758D29CE6A1%7C%E7%99%BD%E9%B9%BF%E5%8E%9F_White.Deer.Plain_2012_BD.rmvb%7C"
MsgBox(32, "", _URLEncodeToString($encode2, 4))
Func _URLEncodeToString($URL_str, $Encode = 1)
;afan 提示:转换经ANSI(GB2312)URL编码后的字符串为原始字符串
;$URL_str - URL编码字符串
;$Encode - URL编码格式 ;1 (默认) = ANSI ;2 = UTF16 小 ;3 = UTF16 大 ;4 = UTF8
;返回值:成功 - 返回编码字符串的原始字符串; 失败 - 返回原字符串并设置 @Error = 1
Local $Rstr, $aSR, $str_Tmp, $i
$Rstr = StringReplace($URL_str, '+', ' ')
$aSR = StringRegExp($Rstr, '(?:%\w{2})+', 3)
If @error Then Return SetError(1, 0, $Rstr)
For $i = 0 To UBound($aSR) - 1
$str_Tmp = BinaryToString('0x' & StringReplace($aSR[$i], '%', ''), $Encode)
$Rstr = StringReplace($Rstr, $aSR[$i], $str_Tmp, 1)
Next
Return $Rstr
EndFunc ;==>_URLEncodeToString
|