Skip to content

Fix Unpaired Surrogate Encoding#157

Merged
rvagg merged 3 commits into
rvagg:masterfrom
DavidBuchanan314:unpaired-surrogates
Jan 19, 2026
Merged

Fix Unpaired Surrogate Encoding#157
rvagg merged 3 commits into
rvagg:masterfrom
DavidBuchanan314:unpaired-surrogates

Conversation

@DavidBuchanan314

@DavidBuchanan314 DavidBuchanan314 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

Fixes #156

Adds new test cases for encode and decode of unpaired surrogates (Note: I've only run the tests in nodejs thus far).

Fixes utf8ToBytes() behaviour to match that of Buffer.from(string), i.e. to encode unmatched surrogates as U+FFFD, and thus the behaviour is now the same for strings <64 and >64 in length.

I didn't make any changes to the decode behaviour because that seems good already (it performs U+FFFD substitution).

@rvagg rvagg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks for chasing this down

@rvagg rvagg merged commit 362856c into rvagg:master Jan 19, 2026
9 checks passed
github-actions Bot pushed a commit that referenced this pull request Jan 19, 2026
## [4.4.0](v4.3.2...v4.4.0) (2026-01-19)

### Features

* **encode:** Allow ignoring `undefined` plain object properties ([a0db184](a0db184)), closes [#155](#155)
* **token:** add Type.equals() for bundler-safe type comparison ([#159](#159)) ([b3e7cf4](b3e7cf4)), closes [#136](#136)

### Bug Fixes

* **encode:** replace unpaired surrogates with U+FFFD in utf8ToBytes ([#157](#157)) ([362856c](362856c))

### Trivial Changes

* **ci:** OIDC publishing ([743ecc3](743ecc3))
* **deps-dev:** bump @types/node from 24.10.3 to 25.0.0 ([#153](#153)) ([20f9e4f](20f9e4f))
* **deps:** bump actions/setup-node from 6.1.0 to 6.2.0 ([#158](#158)) ([feafeb2](feafeb2))
* minor optimisation & test additions for ignoreUndefinedProperties ([55f653c](55f653c))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accepts unpaired surrogate codepoints in both encode and decode

2 participants