The utf8.fromBytes routine does not handle 4-byte character sequences.
Demo
$ echo -n 𠜎 | hexdump
0000000 f0 a0 9c 8e
The character 𠜎 has a 4-byte encoding, so let's try putting that into fromBytes:
const aesjs = require('aes-js')
const bytes = [0xf0, 0xa0, 0x9c, 0x8e]
const string = aesjs.utils.utf8.fromBytes(bytes)
console.log(string)
Nothing prints. Doing it with buffer works as expected:
console.log(Buffer.from(bytes).toString()) // Prints 𠜎
The
utf8.fromBytesroutine does not handle 4-byte character sequences.Demo
The character
𠜎has a 4-byte encoding, so let's try putting that intofromBytes:Nothing prints. Doing it with buffer works as expected: