diff options
Diffstat (limited to 'std/encoding/utf8.ts')
-rw-r--r-- | std/encoding/utf8.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/std/encoding/utf8.ts b/std/encoding/utf8.ts new file mode 100644 index 000000000..266c61165 --- /dev/null +++ b/std/encoding/utf8.ts @@ -0,0 +1,15 @@ +/** A default TextEncoder instance */ +export const encoder = new TextEncoder(); + +/** Shorthand for new TextEncoder().encode() */ +export function encode(input?: string): Uint8Array { + return encoder.encode(input); +} + +/** A default TextDecoder instance */ +export const decoder = new TextDecoder(); + +/** Shorthand for new TextDecoder().decode() */ +export function decode(input?: Uint8Array): string { + return decoder.decode(input); +} |