-
Couldn't load subscription status.
- Fork 205
Closed
Description
Hi there!
I am currently working a on StringDecoder implementation for llrt.
One thing that I currently test for is the following:
const decoder = new StringDecoder('utf16le');
let res = "";
res += decoder.write(Buffer.of(0x3d, 0xd8));
res += decoder.write(Buffer.of(0x61, 0x00));
res += decoder.end();
expect(res).toEqual("\uD83Da");The 0x3d, 0xd8 is an invalid high surrogate for 0x61, 0x00, the UTF-16 spec says that in such a case we should keep the high surrogate as is. But there is no way to encode that in a UTF-8 C String.
Node likely has direct access to the UTF-16 String of V8.
This is an edge case I know, but having direct access to the underlining string would also reduce the amount of copies when going back/forth between the engine and the caller.
HuangJian
Metadata
Metadata
Assignees
Labels
No labels