Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ class C
s = 'str'
trap(:INT){p s}
}.join
rescue => Ractor::RemoteError
rescue Ractor::RemoteError
a << :ok
end
}
Expand Down
9 changes: 7 additions & 2 deletions lib/unicode_normalize/normalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,22 @@ def self.nfc_one(string)
start = nfd_string[0]
last_class = CLASS_TABLE[start]-1
accents = ''
result = ''
nfd_string[1..-1].each_char do |accent|
accent_class = CLASS_TABLE[accent]
if last_class<accent_class and composite = COMPOSITION_TABLE[start+accent]
start = composite
elsif accent_class == 0
result += start+accents
start = accent
accents = ''
last_class = -1
else
accents << accent
last_class = accent_class
end
end
accents = nfc_one(accents) if accents.length>1 # TODO: change from recursion to loop
hangul_comp_one(start+accents)
hangul_comp_one(result+start+accents)
end

def self.normalize(string, form = :nfc)
Expand Down
9 changes: 9 additions & 0 deletions test/test_unicode_normalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ def test_us_ascii
assert_equal true, ascii_string.unicode_normalized?(:nfkd)
end

def test_bug_21559
str = "s\u{1611e}\u{323}\u{1611e}\u{307}\u{1611f}"
assert_equal str.unicode_normalize(:nfd), str.unicode_normalize(:nfc).unicode_normalize(:nfd)
end

def test_gurung_khema
assert_equal "\u{16121 16121 16121 16121 16121 1611E}", "\u{1611E 16121 16121 16121 16121 16121}".unicode_normalize
end

def test_canonical_ordering
a = "\u03B1\u0313\u0300\u0345"
a_unordered1 = "\u03B1\u0345\u0313\u0300"
Expand Down