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)) }
60 queries in 2.037 seconds |