Skip to content

utf8.encode fails to validate input #81

@ChALkeR

Description

@ChALkeR

Doc: https://www.stablelib.com/functions/_stablelib_utf8.encode.html

Encodes the given string into UTF-8 byte array. Throws if the source string has invalid UTF-16 encoding.

Contrary to the documentation, it doesn't work

> require('@stablelib/utf8').encode('\ud800') // ok
Uncaught Error: utf8: invalid string
> require('@stablelib/utf8').encode('\udfff') // fail
Uint8Array(3) [ 237, 191, 191 ]
> '\udfff'.isWellFormed()
false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions