Repository navigation
fix[deburr]: keep letters of non-Latin scripts as they are - #2124
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
`deburr` normalized the whole string with NFD and stripped combining marks, which decomposed Hangul syllables into jamo, turned Cyrillic `й` into `и`, and stripped accents from Greek, Indic, and Arabic letters. Deburr each character on its own instead: a character is only decomposed when its base is an ASCII Latin letter or one of the special Latin letters in `deburrMap`. Everything else is returned unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Only characters in U+00C0-U+0233, U+1E00-U+1EF9, and U+212A-U+212B decompose into a Latin base, so check the code point before calling `normalize()` instead of inspecting the decomposed base afterwards. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
raon0211
force-pushed
the
fix/deburr-non-latin
branch
from
September 30, 2026 05:57
4744572 to
4ec7c2a
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deburrines-toolkitnormalizes the whole string with NFD and then strips combining marks. NFD decomposes every character it can, not just Latin letters, so text in other scripts is corrupted:The docs already promise that Korean text survives (
deburr('résumé-김철수.pdf') // 'resume-김철수.pdf'), but the returned string was decomposed jamo that only looked the same.This is the
es-toolkitcounterpart of #2123, which fixes the same problem ines-toolkit/compatby porting Lodash's fixed table.es-toolkitkeeps its broader behavior of deburring any Latin letter with diacritics, such asTiếng Việt→Tieng VietandǍ→A, which Lodash does not handle.Changes
normalize().U+00C0–U+017Frange still matches Lodash andes-toolkit/compatfor every code point.≠(=+ U+0338) and the Greek question mark;, are now kept as they are since they are not letters. This is the only intentional behavior change for Latin-range input.main: Hangul syllable length, Cyrillic/Greek/Kana preservation, Indic/Arabic preservation, Latin letters outside the Lodash range, letters decomposing intoÆ/Ø/ſ, surrogate pairs, and a fullU+00C0–U+017Fcomparison againstes-toolkit/compat.An exhaustive check of every code point in U+0080–U+10FFFF confirmed that whenever the NFD base is an ASCII letter, every remaining code unit is a combining mark in the removed ranges, so the per-character rule never leaves partial decompositions behind.
Benchmark results
Measured with Node.js 24 on Linux, total time for the given number of calls (lower is better). Non-Latin characters skip
normalize()entirely, so strings made mostly of other scripts are faster than onmain. Latin strings pay for onenormalize()per character instead of one per string.maindeburr('déjà vu')×200k'déjà vu'.repeat(1000)×300deburr('hello world foo bar')×200kdeburr('한국어 테스트 문자열')×200kdeburr('Café Москва 한국어 Tiếng Việt')×100k🤖 Generated with Claude Code