Tag

TextDecoder

1 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Aug 16, 2024 · Fundamentals

Why Emoji Turn into Question Marks? Master Unicode Encoding and Fix Socket Transmission

This article explains why emojis become garbled when transmitted via sockets, explores Unicode encoding fundamentals—including UTF‑8, BMP and high‑code‑point characters—and provides practical solutions using codePointAt, TextEncoder, and TextDecoder to ensure correct emoji handling.

SocketTextDecoderTextEncoder
0 likes · 11 min read
Why Emoji Turn into Question Marks? Master Unicode Encoding and Fix Socket Transmission
Sohu Tech Products
Sohu Tech Products
Dec 6, 2023 · Frontend Development

The Nuances of Base64 Encoding Strings in JavaScript

The article explains that JavaScript’s native btoa() and atob() functions only handle ASCII, so to correctly base64‑encode Unicode strings you must convert them with TextEncoder to UTF‑8 bytes, use Uint8Array, and decode with TextDecoder, while checking for malformed surrogate pairs via isWellFormed or encodeURIComponent to avoid silent data loss.

Base64TextDecoderTextEncoder
0 likes · 14 min read
The Nuances of Base64 Encoding Strings in JavaScript