Skip to content

Allow UTF-16 String access #992

@Sytten

Description

@Sytten

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions