Files
HanaandGitHub de7b440a64 fix(es/ast): Fix unicode unpaired surrogates handling (#11144)
**Description:**

This PR reapplied https://github.com/swc-project/swc/pull/10987 and
replaced `lone_surrogates: bool` mark with `Wtf8Atom`. `lone_surrogates`
introduced in https://github.com/swc-project/swc/pull/10987 is more of
an implicit mark, whereas the use of `Wtf8Atom` makes it more explicit
where users need to explicitly call `to_string_lossy` to get the lossy
UTF-8 result, making a huge difference from the original implementation
where users need to convert `\uFFFDxxx` into the correct unicode.

**BREAKING CHANGE:**

Both `cooked` in `TemplateElement` and `value` in `StringLiteral` are
replaced with `Wtf8Atom` introduced in
https://github.com/swc-project/swc/pull/11104.

`Wtf8Atom` does not expose a `to_string` method like the old `Atom`
does. Internally, it stores the code points of the characters. You can
call `code_points()` to get an iterator of the code points or call
`to_string_lossy()` to get an lossy string in which all unpaired
surrogates are replaced with `U+FFFD`(Replacement Character).
2025-10-27 15:43:10 +09:00
..