rong_encoding
文本编码 / 解码
本页 API 参考由仓库内的英文文档生成,暂仅提供英文版。
Encoding
Text encoding/decoding and Base64 conversion.
TextEncoder
const encoder = new TextEncoder();
const bytes = encoder.encode("Hello World"); // Uint8Array
TextDecoder
const decoder = new TextDecoder();
const text = decoder.decode(new Uint8Array([72, 101, 108, 108, 111]));
// "Hello"
Base64
const encoded = btoa("Hello"); // "SGVsbG8="
const decoded = atob("SGVsbG8="); // "Hello"