请教高人转换代码!!!
本帖最后由 论坛管理员 于 2009-8-13 20:50 编辑<html>
<body>
<script type="text/javascript">
document.write(encodeURIComponent("你好"))
</script>
</body>
</html>
输出结果为:%E4%BD%A0%E5%A5%BD
请教高人弄个 函数、UDF 出来 !谢谢! 这个是URL转码,php有个函数叫urlencode可以实现
AU3的还没有,不知道有什么规则 <script language="JavaScript" tpye="text/javascript">
var name; // name 是变量
name=prompt("输入",""); // prompt()方法
alert(encodeURIComponent(name));
</script>
生成一个页面如上代码,再用autoit抓窗口,输入和获取输出吧。
MsgBox(0,0,_StringToUTF8("你好"))
Func _StringToUTF8($sString)
$buffer = StringToBinary($sString, 4)
$buffer = StringRegExpReplace($buffer ,"\w{2}","\0%")
$buffer =StringTrimRight(StringReplace($buffer, "0x", ""),1)
Return $buffer
EndFunc
真正的管理员一出马,果然非同凡响!
就是多了点小尾巴,不知道是否版本问题?
%E4%BD%A0%E5%A5%BD
%E4%BD%A0%E5%A5%BD%E5%89%85%00
谢谢! 我这正常~ 输出结果为:%E4%BD%A0%E5%A5%BD 无意中从老外的代码里面看到的
Func GetURI($url)
$uri = StringMid($url, 1, StringInStr($url, "://")) & "//"
$turl = StringMid($url, StringLen($uri) + 1)
If StringInStr($turl, "?") Then
$temp = StringSplit($turl, "?")
$turl = $temp
$temp = StringSplit($turl, "/")
$uri = $uri & $temp & "/"
For $i = 2 To UBound($temp) - 1 Step 1
If StringInStr($temp[$i], ".") Or Not StringLen($temp[$i]) Then ExitLoop
$uri = $uri & $temp[$i] & "/"
Next
If Not InetGetSize(StringLeft($uri, StringLen($uri) - 1)) Then
$uri = StringMid($url, 1, StringInStr($url, "://")) & "//"
$temp = StringSplit($turl, "?")
$turl = $temp
$temp = StringSplit($turl, "/")
$uri = $uri & $temp & "/"
For $i = 2 To UBound($temp) - 2 Step 1
If StringInStr($temp[$i], ".") Or Not StringLen($temp[$i]) Then ExitLoop
$uri = $uri & $temp[$i] & "/"
Next
EndIf
Else
$temp = StringSplit($turl, "/")
$uri = $uri & $temp & "/"
For $i = 2 To UBound($temp) - 1 Step 1
If StringInStr($temp[$i], ".") Or Not StringLen($temp[$i]) Then ExitLoop
$uri = $uri & $temp[$i] & "/"
Next
EndIf
Return $uri
EndFunc;==>GetURI
页:
[1]