Skip to content

string mod function, code_point_at, does not return correct code point of lone high surrogate #1632

Closed

Description

@jtara1

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'

boa

console.log('\uD800'.codePointAt(0));
65533

To Reproduce

// lone high surrogate
console.log('\uD800'.codePointAt(0)); // 55296

// lone low surrogate
console.log('\uDFFF'.codePointAt(0)); // 57343

Build environment (please complete the following information):

  • Rustc version: rustc 1.55.0 (c8dfcfe04 2021-09-06)

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.

Activity

  1. added
    A-Bug
    on Oct 4, 2021
  2. 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
  3. jedel1043 commented on Oct 5, 2021

    @jedel1043
    Member

    Assigned then :)

  4. added
    C-Builtins
    Hacktoberfest
    on Oct 5, 2021
  5. jtara1 commented on Oct 5, 2021

    @jtara1
    Author

    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
    
  6. jedel1043 commented on Oct 5, 2021

    @jedel1043
    Member

    Yeah, this is probably blocked until we solve #736.

  7. added
    Blocked
    and removed
    Hacktoberfest
    on Oct 5, 2021
  8. removed their assignment
    on Oct 14, 2021
  9. Razican commented on Oct 21, 2022

    @Razican
    Member

    This was closed in #1659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BugBlockedC-Builtins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions