const ec = new TextEncoder() const dc = new TextDecoder() /** * Converts a UTF-8 string to bytes using TextEncoder. * @param str - String to convert * @returns Uint8Array containing the UTF-8 encoded bytes */ export function str_to_bytes ( str : string ) : Uint8Array { return ec.encode(str) } /** * Converts bytes to a UTF-8 string using TextDecoder. * @param bytes - Uint8Array to decode * @returns Decoded UTF-8 string */ export function bytes_to_str ( bytes : Uint8Array ) : string { return dc.decode(bytes) }