unicode/norm: compose non-Hangul pairs inside a Hangul buffer - #70
Open
tannevaled wants to merge 1 commit into
Open
unicode/norm: compose non-Hangul pairs inside a Hangul buffer#70tannevaled wants to merge 1 commit into
tannevaled wants to merge 1 commit into
Conversation
Contributor
|
This PR (HEAD: 85fdcd5) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/821040. Important tips:
|
Contributor
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/821040. |
tannevaled
force-pushed
the
norm-hangul-buffer-drops-composition
branch
from
August 26, 2026 12:31
85fdcd5 to
bacb127
Compare
Contributor
|
This PR (HEAD: bacb127) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/821040. Important tips:
|
A V or T jamo anywhere in the reorder buffer diverts the whole segment to
combineHangul, and its default arm copies a character through without ever
consulting the composition table. Anything in that segment that is not an
L+V or LV+T pair therefore stops composing.
norm.NFC.String("가\U000113C5")
got "가\U000113C2\U000113C2"
want "가\U000113C5"
U+113C5 decomposes to <U+113C2, U+113C2>. U+113C2 combines backward, so it
does not begin a new segment and the pair has to recompose inside the Hangul
buffer, which is where it is lost. The same string composes correctly on its
own and after a starter that does begin a new segment, so the result depends
on unrelated preceding context.
Fall back to combine() before copying through.
Only reachable with the Unicode 16 tables or later: it needs a ccc=0
character that both combines backward and combines forward, and there are
none in Unicode 15 and exactly four from Unicode 16 -- U+113C2, U+1611E,
U+16129 and U+16D67. The added test states an expectation that holds either
way, since a table set without U+113C5 has no decomposition to undo; under
Unicode 15 tables it passes with or without this change, and under
Unicode 17 it fails without it:
it fails without it:
normalize_test.go:613: "가\U000113c5": length is 11; want 7
("가\U000113c2{2}" vs "가\U000113c5")
go test -long ./unicode/norm, which runs TestStandardTests and
TestCharacterByCharacter against the real UCD, gives 24079 tests and no
failures under both go1.26.4 and go1.27.0.
Checked beyond the package's own tests: NFC, NFKC and NFD of 2194559
inputs weighted towards Hangul were compared before and after, and each
of the 86234 differing results was judged by a separate UAX golang#15
implementation built from UnicodeData.txt -- itself checked against
NormalizationTest.txt at 305184 assertions under Unicode 15 and 320544
under Unicode 17 with no failures. 86230 of them are corrections and
none is a regression. The remaining four are golang/go#81001, which is
independent and fixed by CL 821020; with both changes applied all 88743
differences are corrections and none is left.
Fixes golang/go#81021
tannevaled
force-pushed
the
norm-hangul-buffer-drops-composition
branch
from
August 26, 2026 12:35
bacb127 to
c2e52ee
Compare
Contributor
|
This PR (HEAD: c2e52ee) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/821040. Important tips:
|
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.
A V or T jamo anywhere in the reorder buffer diverts the whole segment to
combineHangul, and its default arm copies a character through without ever
consulting the composition table. Anything in that segment that is not an
L+V or LV+T pair therefore stops composing.
U+113C5 decomposes to <U+113C2, U+113C2>. U+113C2 combines backward, so it
does not begin a new segment and the pair has to recompose inside the Hangul
buffer, which is where it is lost. The same string composes correctly on its
own and after a starter that does begin a new segment, so the result depends
on unrelated preceding context.
Fall back to combine() before copying through.
Only reachable with the Unicode 16 tables or later: it needs a ccc=0
character that both combines backward and combines forward, and there are
none in Unicode 15 and exactly four from Unicode 16 -- U+113C2, U+1611E,
U+16129 and U+16D67. The added test states an expectation that holds either
way, since a table set without U+113C5 has no decomposition to undo; under
Unicode 15 tables it passes with or without this change, and under
Unicode 17 it fails without it:
it fails without it:
go test -long ./unicode/norm, which runs TestStandardTests and
TestCharacterByCharacter against the real UCD, gives 24079 tests and no
failures under both go1.26.4 and go1.27.0.
Checked beyond the package's own tests: NFC, NFKC and NFD of 2194559
inputs weighted towards Hangul were compared before and after, and each
of the 86234 differing results was judged by a separate UAX #15
implementation built from UnicodeData.txt -- itself checked against
NormalizationTest.txt at 305184 assertions under Unicode 15 and 320544
under Unicode 17 with no failures. 86230 of them are corrections and
none is a regression. The remaining four are golang/go#81001, which is
independent and fixed by CL 821020; with both changes applied all 88743
differences are corrections and none is left.
Fixes golang/go#81021