Pass Chinese parameters, and then modify the database tutorial.
| The code is as follows: |
Copy code |
|
<Script>
Var url = "admin/ajaxmodify. php? "+ Key +" = ";
Url + = encodeuricomponent (value ));
Xmlhttp. open ("get", url, true );
Xmlhttp. send (null );
</Script>
The parameter is Chinese. encodeuricomponent. This method must be called twice.
*/
Function utf8rawurldecode ($ source ){
$ Decodedstr = "";
$ Pos = 0;
$ Len = strlen ($ source );
While ($ pos <$ len ){
$ Charat = substr ($ source, $ pos, 1 );
If ($ charat = '% '){
$ Pos ++;
$ Charat = substr ($ source, $ pos, 1 );
If ($ charat = 'u '){
// We got a unicode character
$ Pos ++;
$ Unicodehexval = substr ($ source, $ pos, 4 );
$ Unicode = hexdec ($ unicodehexval );
$ Entity = "& #". $ unicode .';';
$ Decodedstr. = utf8_encode ($ entity );
$ Pos + = 4;
}
Else {
// We have an escaped ascii character
$ Hexval = substr ($ source, $ pos, 2 );
$ Decodedstr. = chr (hexdec ($ hexval ));
$ Pos + = 2;
}
} Else {
$ Decodedstr. = $ charat;
$ Pos ++;
}
}
Return $ decodedstr;
} |
/*
Note: In js, encodeuricomponent () or encodeuri () is recommended for character transcoding, rather than escape (). The reason is that escape () only converts ascii characters to % unnnn. If you want to use more characters, such as the UTF-8 character library, you must use encodeuricomponent () or encodeuri () can be converted to % nn.
Js: encodeuricomponent -- decodeuricomponent; php: rawurlencode -- rawurldecode
*/