You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
string mod function, code_point_at, does not return correct code point of lone high surrogate #1632
Describe the bug
I expected the code point of this malformed utf-16 string, '\uD800'
to be 55296
node.js 14
$ node
Welcome to Node.js v14.17.5.
Type ".help" for more information.
> let s
undefined
> s = '\uD800';
'�'
> s.codePointAt(0)
55296
> s.codePointAt(0).toString(16)
'd800'
Additional context
I was working on #894 when I realized something seems wrong with code_point_at func. Maybe #736 is relevant. You can assign this issue to me for unit testing.
changed the title [-]string mod `code_point_at` does not return correct code point of lone high surrogate[/-][+]string mod function, `code_point_at`, does not return correct code point of lone high surrogate[/+]on Oct 4, 2021
I'm not sure how we'd detect that it's a malformed unicode encoded string. By the time we encode the JsString as utf-16, it appears to be an acceptable string. I think I'd need to determine if it's malformed from the bytes of the input string.
Rust
let c = string.as_str().as_bytes(); // [239, 191, 189] where string is JsValue with value "\uD800"
// same value if we encode string as utf-8
Activity
[-]string mod `code_point_at` does not return correct code point of lone high surrogate[/-][+]string mod function, `code_point_at`, does not return correct code point of lone high surrogate[/+]jedel1043 commentedon Oct 5, 2021
Assigned then :)
jtara1 commentedon Oct 5, 2021
I'm not sure how we'd detect that it's a malformed unicode encoded string. By the time we encode the JsString as utf-16, it appears to be an acceptable string. I think I'd need to determine if it's malformed from the bytes of the input string.
Rust
jedel1043 commentedon Oct 5, 2021
Yeah, this is probably blocked until we solve #736.
Razican commentedon Oct 21, 2022
This was closed in #1659