Repository navigation
Match letters longer than one code unit when reading Brahmic scripts - #71
Merged
vvasuki merged 1 commit intoNov 26, 2026
Conversation
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.
Fixes #26, fixes #63.
transliterateBrahmicreads one UTF-16 code unit at a time, so letters outside the BMP never match. Text in Grantha, Sharada, Brahmi, Newa, Siddham etc. comes back unchanged:The same happens to letters made of two characters, like
க³intamil_superscriptedor a letter with nukta.It now takes the longest token from the map at each position, like
transliterateRomanand the Python version do.I ran 3000 random Devanagari words through Devanagari → script → Devanagari. Grantha, Sharada and Newa go from 3000 mismatches to 0, Javanese from 1543 to 0,
tamil_superscriptedfrom 2603 to 0, Siddham from 3000 to 6. No scheme got worse. What is left in other scripts are letters that share a sign in the map.One old test value changes: Devanagari → Gurmukhi expected
ਕ੍षੇ, with a Devanagariषleft in. The map has an entry forक्ष, which is used now (ਕ੍ਸ਼ੇ, same as the Python version).The new test fails without the change. A text of 215,000 characters takes 30 ms instead of 13 ms here.