recommendations: the best use of a unified whole project encoding, such as UTF-8 (either the page or in the coding filter)
transcoding the most basic way is not to say here, is to use the traditional way of transcoding, where I introduced a few species encountered in the work I garbled:
1, if there are also transferred, but transcode to come, but try to open the tomcat's server.xml, find
function escape (charString: String): String
parameters
charString
Required. String to encode any object or text.
Note
escape method returns a string value containing the content charstring (Unicode format). All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with% xx encoding, where xx is equal to that of the character hexadecimal number. For example, the space returned as
character value is greater than 255 characters to% uxxxx format.
method can not be used to escape attention, EncodeURI and its encoding should use the encodeURIComponent method.
escape character is not coded 69 :*,+,-,.,/,@,_, 0-9, az, AZ
encodeURI () method returns the encoding as a valid
Uniform Resource Identifier (URI) strings.
function encodeURI (URIString: String): String
parameters
URIString
Required. That encoded URI string.
Note
encodeURI method returns an encoded URI. If the result code passed to the decodeURI, will return the initial string. The following characters are not encoded encodeURI :Use encodeURIComponent to encode these characters.
encodeURI not encode characters in 82 :!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_, ~ ,0-9, az, AZ
encodeURIComponent () method returns
encoded as a Uniform Resource Identifier (URI) of the effective components of the string.
function encodeURIComponent (encodedURIString: String): String
parameters
encodedURIString
Required. That encoded URI component string.
Note
encodeURIComponent method returns an encoded URI. If the result code passed to the decodeURIComponent, will return the initial string. EncodeURIComponent method because all the characters will be encoded, please note that if the string represents a path, for example / folder1/folder2/default.html, is one of the slash will be encoded, so that when the string as a request sent to the Web server, it will be invalid. If the string contains multiple URI components, use encodeURI tested.
It is the Chinese, Korean and other special characters into utf-8 url encoding format, if your page is gb2312 encoding, then the server receives will be garbled.
encodeURIComponent encoding characters are not 71:!,',(,),*,-,.,_,~, 0-9, az, AZ
so the data can be used when using js escape , the data for the address bar, preferably encoded with encodeURIComponent.
Thus, for Chinese string, if string encoding format do not want to convert UTF-8 format (such as the original page and the target page when the charset is the same), only need to use escape. If your page is GB2312 or other code, and accept the parameters of the page is UTF-8 encoded, it is necessary or using encodeURI encodeURIComponent.
unescape () method
escape methods from encoded using String objects returns the decoded string.
function unescape (charString: String): String
parameters
charString
Required. To decode the String object or text.
Note
unescape method returns a string value containing charstring content. All the% xx hexadecimal encoding of the ASCII character set with characters which are equivalent to the character instead.
to% uxxxx format (Unicode characters) in hexadecimal character encoding of the Unicode character encoding instead of xxxx.
Note unescape method not be used to decode the Use decodeURI and decodeURIComponent methods.
requirements
version 1
see
decodeURI methods | decodeURIComponent Method | escape Method | String Object
for: Global Objects
decodeURI ( ) method returns an encoded
Uniform Resource Identifier (URI) of the non-encoded form.
function decodeURI (URIstring: String): String
parameters
URIstring
Required. That encoded URI string.
Note
method instead of using the outdated decodeURI unescape method.
decodeURI method returns a string value.
invalid if URIString will occur URIError.
requires version 5.5
see
decodeURIComponent methods | encodeURI method
for: Global Objects
decodeURIComponent () method < br> Back to the Uniform Resource Identifier (URI) in a coded form of non-coding components.
function decodeURIComponent (encodedURIString: String): String
Required encodedURIString argument is a URI that encoded the value of the component.
Note
URIComponent is part of a complete URI.
If encodedURIString invalid, it will produce URIError.
requires version 5.5
see
decodeURI methods | encodeURI method
for: Global Objects
addition, encodeURI / encodeURIComponent After the introduction in javascript1.5, escape there in the javascript1.0 version.
3, using the struts2
没有评论:
发表评论