JS Built-ins
TextEncoderadvanced

TextEncoder β€” encode multi-byte character

πŸ“– Usage Example
new TextEncoder().encoding === 'utf-8'  // β†’ true

All TextEncoder instances use UTF-8; it is the only supported encoding.

UTF-8 Multi-byte Encoding

The Euro sign '€' (U+20AC) requires 3 bytes in UTF-8.

UTF-8 encodes code points > U+07FF using 3 or 4 bytes. U+20AC encodes as 0xE2 0x82 0xAC.

Challenge: Verify that encode('€').length === 3.

πŸ’‘ Hints (1)
  • β€’ U+20AC (€) is encoded as 3 bytes in UTF-8: 0xE2, 0x82, 0xAC.