Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. JavaScript error reference
  5. URIError: malformed URI sequence

URIError: malformed URI sequence

The JavaScript exception "malformed URI sequence" occurs when URI encoding or decodingwasn't successful.

Message

URIError: URI malformed (V8-based)URIError: malformed URI sequence (Firefox)URIError: String contained an illegal UTF-16 sequence. (Safari)

Error type

URIError

What went wrong?

URI encoding or decoding wasn't successful. An argument given to either thedecodeURI,encodeURI,encodeURIComponent, ordecodeURIComponent function was not valid, so that the function was unableencode or decode properly.

Examples

Encoding

Encoding replaces each instance of certain characters by one, two, three, or fourescape sequences representing the UTF-8 encoding of the character. AnURIError will be thrown if there is an attempt to encode a surrogate whichis not part of a high-low pair, for example:

js
encodeURI("\uD800");// "URIError: malformed URI sequence"encodeURI("\uDFFF");// "URIError: malformed URI sequence"

A high-low pair is OK. For example:

js
encodeURI("\uD800\uDFFF");// "%F0%90%8F%BF"

Decoding

Decoding replaces each escape sequence in the encoded URI component with the characterthat it represents. If there isn't such a character, an error will be thrown:

js
decodeURIComponent("%E0%A4%A");// "URIError: malformed URI sequence"

With proper input, this should usually look like something like this:

js
decodeURIComponent("JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B");// "JavaScript_шеллы"

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp