URL符号化変換,escape()encodeURI()encodeURIComponent()
3731 ワード
Escape()メソッド:
指定した文字列をISO Latin文字セットで符号化します.すべてのスペース記号、句読点、特殊文字、およびその他の非ASCII文字は、%xx形式の文字符号化に変換されます(xxは、文字セットテーブル内の文字の符号化の16進数に等しい).たとえば、スペース記号に対応する符号化は%20です.unescapeメソッドはこれとは逆です.このメソッドで符号化されない文字:@*/+
MSDN Jscript Reference:The escape method returns a string value(in Unicode format)that contains the contents of[the argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as "%20."
Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value.
EncodeURI()メソッド:URI文字列をUTF-8符号化フォーマットでescapeフォーマットの文字列に変換します.このメソッドで符号化されない文字:! @ # $& * ( ) = : / ; ? + '
MSDN Jscript Reference:The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters. Edge Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character
EncodeURIComponent()メソッド:URI文字列をUTF-8符号化フォーマットでescapeフォーマットの文字列に変換します.この方法は、encodeURI()に比べて、/などの文字など、より多くの文字を符号化する.したがって文字列にURIのいくつかの部分が含まれている場合、この方法で符号化することはできません.そうしないと、/文字が符号化された後にURLにエラーが表示されます.このメソッドで符号化されない文字:! * ( )
MSDN Jscript Reference:The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1/folder2/default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a single URI component. Mozilla Developer Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.
なお、encodeURI/encodeURIComponentはjavascript 1である.5以降に導入する、escapeはjavascript 1にある.0バージョンがあります.
英文注釈:The escape()method does not encode the+character which is interpreted as a space on the server side as well as generated by forms with spaces in their fields. Due to this shortcoming, you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent().Use of the encodeURI() method is a bit more specialized than escape() in that it encodes for URIs [REF] as opposed to the querystring, which is part of a URL. Use this method when you need to encode a string to be used for any resource that uses URIs and needs certain characters to remain un-encoded. Note that this method does not encode the ' character, as it is a valid character within URIs.Lastly, the encodeURIComponent() method should be used in most cases when encoding a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included. Note that this method does not encode the ' character, as it is a valid character within URIs.
指定した文字列をISO Latin文字セットで符号化します.すべてのスペース記号、句読点、特殊文字、およびその他の非ASCII文字は、%xx形式の文字符号化に変換されます(xxは、文字セットテーブル内の文字の符号化の16進数に等しい).たとえば、スペース記号に対応する符号化は%20です.unescapeメソッドはこれとは逆です.このメソッドで符号化されない文字:@*/+
MSDN Jscript Reference:The escape method returns a string value(in Unicode format)that contains the contents of[the argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as "%20."
Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value.
EncodeURI()メソッド:URI文字列をUTF-8符号化フォーマットでescapeフォーマットの文字列に変換します.このメソッドで符号化されない文字:! @ # $& * ( ) = : / ; ? + '
MSDN Jscript Reference:The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters. Edge Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character
EncodeURIComponent()メソッド:URI文字列をUTF-8符号化フォーマットでescapeフォーマットの文字列に変換します.この方法は、encodeURI()に比べて、/などの文字など、より多くの文字を符号化する.したがって文字列にURIのいくつかの部分が含まれている場合、この方法で符号化することはできません.そうしないと、/文字が符号化された後にURLにエラーが表示されます.このメソッドで符号化されない文字:! * ( )
MSDN Jscript Reference:The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1/folder2/default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a single URI component. Mozilla Developer Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.
, , UTF-8 ( charset ), escape。 GB2312 , UTF-8 , encodeURI encodeURIComponent。
なお、encodeURI/encodeURIComponentはjavascript 1である.5以降に導入する、escapeはjavascript 1にある.0バージョンがあります.
英文注釈:The escape()method does not encode the+character which is interpreted as a space on the server side as well as generated by forms with spaces in their fields. Due to this shortcoming, you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent().Use of the encodeURI() method is a bit more specialized than escape() in that it encodes for URIs [REF] as opposed to the querystring, which is part of a URL. Use this method when you need to encode a string to be used for any resource that uses URIs and needs certain characters to remain un-encoded. Note that this method does not encode the ' character, as it is a valid character within URIs.Lastly, the encodeURIComponent() method should be used in most cases when encoding a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included. Note that this method does not encode the ' character, as it is a valid character within URIs.