Kinn. util. encodeuri =Function(Unzipstr, iscusencode ){ |
If(Iscusencode ){ |
VaRZiparray =New Array(); |
VaRZipstr =""; |
VaRLens =New Array(); |
For(VaRI = 0; I <unzipstr.Length; I ++ ){ |
VaRAC = unzipstr. charcodeat (I ); |
Zipstr + = ac; |
Lens = Lens. Concat (AC.Tostring().Length); |
} |
Ziparray = ziparray. Concat (zipstr ); |
Ziparray = ziparray. Concat (lens. Join ("O")); |
ReturnZiparray. Join ("N"); |
}Else{ |
// Return encodeuri (unzipstr ); |
VaRZipstr =""; |
VaRStrspecial ="! \ "# $ % & '() * +,/:; <=>? [] ^ '{| }~ %"; |
VaRTt =""; |
|
For(VaRI = 0; I <unzipstr.Length; I ++ ){ |
VaRCHR = unzipstr. charat (I ); |
VaRC = kinn. util. stringtoascii (CHR ); |
Tt + = CHR +":"+ C +"N"; |
If(Parseint("0x"+ C)> 0x7f ){ |
Zipstr + = encodeuri (unzipstr. substr (I, 1 )); |
}Else{ |
If(CHR =" ") |
Zipstr + ="+"; |
Else If(Strspecial. indexof (CHR )! =-1) |
Zipstr + ="%"+ C.Tostring(16 ); |
Else |
Zipstr + = CHR; |
} |
} |
ReturnZipstr; |
} |
} |
|
Kinn. util. decodeuri =Function(Zipstr, iscusencode ){ |
If(Iscusencode ){ |
VaRZiparray = zipstr. Split ("N"); |
VaRZipsrcstr = ziparray [0]; |
VaRZiplens; |
If(Ziparray [1]) { |
Ziplens = ziparray [1]. Split ("O"); |
}Else{ |
Ziplens.Length= 0; |
} |
|
VaRUzipstr =""; |
|
For(VaRJ = 0; j <ziplens.Length; J ++ ){ |
VaRCharlen =Parseint(Ziplens [J]); |
Uzipstr + =String. Fromcharcode (zipsrcstr. substr (0, charlen )); |
Zipsrcstr = zipsrcstr. Slice (charlen, zipsrcstr.Length); |
} |
ReturnUzipstr; |
}Else{ |
// Return decodeuri (zipstr ); |
VaRUzipstr =""; |
|
For(VaRI = 0; I <zipstr.Length; I ++ ){ |
VaRCHR = zipstr. charat (I ); |
If(CHR ="+"){ |
Uzipstr + =" "; |
}Else If(CHR ="%"){ |
VaRASC = zipstr. substring (I + 1, I + 3 ); |
If(Parseint("0x"+ ASC)> 0x7f ){ |
Uzipstr + = decodeuri ("%"+ ASC.Tostring() + Zipstr. substring (I + 3, I + 9 ).Tostring());; |
I + = 8; |
}Else{ |
Uzipstr + = kinn. util. asciitostring (Parseint("0x"+ ASC )); |
I + = 2; |
} |
}Else{ |
Uzipstr + = CHR; |
} |
} |
ReturnUzipstr; |
} |
} |
|
Kinn. util. stringtoascii =Function(STR ){ |
ReturnStr. charcodeat (0 ).Tostring(16 ); |
} |
|
Kinn. util. asciitostring =Function(Asccode ){ |
Return String. Fromcharcode (asccode ); |
} |