11 lines
261 B
TypeScript
11 lines
261 B
TypeScript
|
const encoder = new TextEncoder()
|
||
|
const decoder = new TextDecoder('utf-8')
|
||
|
|
||
|
export function encodeText(str: string): Uint8Array {
|
||
|
return encoder.encode(str)
|
||
|
}
|
||
|
|
||
|
export function decodeText(bytes: Uint8Array): string {
|
||
|
return decoder.decode(bytes)
|
||
|
}
|