diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-01 15:23:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-01 15:23:39 -0400 |
commit | 12c6b2395be2bd1371284adf03e4826ba5edc761 (patch) | |
tree | ef8bf5a2ef76a43fc044759e98d615fbd1a52e93 /std/encoding/utf8.ts | |
parent | 3a0b617503f4c81fb9773bd99c898270b98b9b5a (diff) |
Move encode, decode helpers to /std/encoding/utf8.ts, delete /std/strings/ (#4565)
also removes std/encoding/mod.ts and std/archive/mod.ts which are useless.
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); +} |