Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JavaScript strings are natively Unicode. They hold character sequences* not byte sequences, so it is impossible for one to contain an invalid byte sequence. </p> <p>(Technically, they actually contain UTF-16 code unit sequences, which is not quite the same thing, but this probably isn't anything you need to worry about right now.)</p> <p>You can, if you need to for some reason, create a string holding characters used as placeholders for bytes. ie. using the character <code>U+0080</code> ('\x80') to stand for the byte 0x80. This is what you would get if you encoded characters to bytes using UTF-8, then decoded them back to characters using ISO-8859-1 by mistake. There is a special JavaScript idiom for this:</p> <pre><code>var bytelike= unescape(encodeURIComponent(characters)); </code></pre> <p>and to get back from UTF-8 pseudobytes to characters again:</p> <pre><code>var characters= decodeURIComponent(escape(bytelike)); </code></pre> <p>(This is, notably, pretty much the only time the <code>escape</code>/<code>unescape</code> functions should ever be used. Their existence in any other program is almost always a bug.)</p> <p><code>decodeURIComponent(escape(bytes))</code>, since it behaves like a UTF-8 decoder, will raise an error if the sequence of code units fed into it would not be acceptable as UTF-8 bytes.</p> <p>It is very rare for you to need to work on byte strings like this in JavaScript. Better to keep working natively in Unicode on the client side. The browser will take care of UTF-8-encoding the string on the wire (in a form submission or XMLHttpRequest).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload