```
const str = '!ABC+** /==🤬';
const bytes = commUtilsModule.encodeStringToUTF8ArrayBuffer(str);
const str2 = commUtilsModule.decodeUTF8ArrayBufferToString(
new Uint8Array(bytes).buffer,
);
console.log(str === str2);
try {
console.log(
commUtilsModule.decodeUTF8ArrayBufferToString(
new Uint8Array([72, 101, 108, 108, 111, 0x80]).buffer,
),
);
} catch (e) {
// should fail
console.log(e);
}
try {
console.log(
commUtilsModule.decodeUTF8ArrayBufferToString(
new Uint8Array([72, 101, 108, 0x80, 111, 111]).buffer,
),
);
} catch (e) {
// should fail
console.log(e);
}
try {
console.log(
commUtilsModule.decodeUTF8ArrayBufferToString(
new Uint8Array([0x80, 101, 108, 108, 111]).buffer,
),
);
} catch (e) {
// should fail
console.log(e);
}
try {
console.log(
commUtilsModule.decodeUTF8ArrayBufferToString(
new Uint8Array([72, 101, 108, 108, 111]).buffer,
),
);
} catch (e) {
// should work
console.log(e);
}
```