Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Encoding API

TheEncoding API enables web developers to work with text that is represented incharacter encodings systems other than the encoding used internally by JavaScript strings. In particular, it enables developers to convert text between JavaScript strings and theUTF-8 encoding that is used for most documents on the web.

It provides two mechanisms:

  • Encoding: taking a JavaScript string and converting it into an array of bytes representing theUTF-8 encoding of the string.
  • Decoding: taking an array of bytes representing a particular character encoding of some text, and converting it into a JavaScript string.

Note that these operations are asymmetrical: encoding only encodes to UTF-8, while decoding can decode UTF-8 but alsomany legacy encoding systems.

The API provides synchronous interfaces for encoding and decoding, and alsostream-based encoders and decoders, which could be used to, for example, decode text as it arrives over a network connection.

Interfaces

TextDecoder

A decoder to convert a byte array containing a particular encoding into a JavaScript string.

TextDecoderStream

A decoder to convert a byte stream containing a particular encoding into a stream of JavaScript strings.

TextEncoder

An encoder to convert a JavaScript string into an array of bytes representing the UTF-8 encoding of the string.

TextEncoderStream

An encoder to convert a stream of JavaScript strings into an stream of bytes representing the UTF-8 encoding of the strings.

Specifications

Specification
Encoding

Browser compatibility

api.TextDecoder

api.TextEncoder

api.TextEncoderStream

api.TextDecoderStream

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp