Thinkai's Blog

Autohotkey|Python|php|aardio|VOIP|IT 爱好者

urlencode 适用于ansi和unicode版本 Autohotkey 3024

作者为 发表

Autohotkey

urlencode(string,encoding:="UTF-8"){
	VarSetCapacity(pstr,ceil(strlen(string)*1.5+10),0)
	StrPut(string,&pstr,,encoding)
	int := "1"
	while (int){
		int := ToBase(NumGet(&pstr,(A_index-1)*4,"Uint"),16)

		RegExMatch(int,"(.{2})(.{2})(.{2})(.{2})",m)
		loop 4
		{
			i := 4-A_index+1
			hex := % m%i%
			if hex
			{
				hex2 := "0x" hex
				If (hex2==33 || (hex2>=39 && hex2 <=42) || hex2==45 || hex2 ==46 || (hex2>=48 && hex2<=57) || (hex2>=65 && hex2<=90) || hex2==95 || (hex2>=97 && hex2<=122) || hex2==126)
					out .= chr("0x" hex)
				else
					out .= "%" hex
			}
		}
	}
	Return out
}


ToBase(n,b){
    return (n < b ? "" : ToBase(n//b,b)) . ((d:=Mod(n,b)) < 10 ? d : Chr(d+55))
}



来了就留个评论吧! 1个评论




友情链接:Autohotkey中文帮助Autohotkey官网Autohotkey中文网联系作者免GooglePlay APK下载

 主题设计 • skyfrit.com  Thinkai's Blog | 保留所有权利

60 queries in 17.184 seconds |