UTF-8 Encoding
This feature allows you to encode a string into UTF-8 format. The `toUtf8` function takes a string as input and returns its UTF-8 encoded version.
const { toUtf8 } = require('@aws-sdk/util-utf8');
const utf8Encoded = toUtf8('Hello, World!');
console.log(utf8Encoded);
UTF-8 Decoding
This feature allows you to decode a UTF-8 encoded array back into a string. The `fromUtf8` function takes a Uint8Array as input and returns the decoded string.
const { fromUtf8 } = require('@aws-sdk/util-utf8');
const utf8Decoded = fromUtf8(new Uint8Array([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]));
console.log(utf8Decoded);