Skip to content

Commit

Permalink
EastAsianWidth.txt Format Change after Unicode 15.1.0 (#585)
Browse files Browse the repository at this point in the history
* fix bin/generate_east_asian_width for Unicode 15.1.0

* fix a regexp of parsing EastAsianWidth.txt line

* Fix to use MatchData#[] instead of Regexp::last_match
  • Loading branch information
elfham authored Aug 23, 2023
1 parent 3840d1f commit 7d2084b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions bin/generate_east_asian_width
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ end
open(ARGV.first, 'rt') do |f|
list = []
f.each_line do |line|
next if line.start_with?(?#)
line.chomp!.sub!(/ .*/, '')
next if line.empty?
range, type = line.chomp.split(';')
type = type.to_sym
if range =~ /\h+\.\.\h+/
first, last = range.split('..').map{ |_| _.to_i(16) }
else
first = last = range.to_i(16)
end
next unless m = line.match(/^(\h+)(?:\.\.(\h+))?\s*;\s*(\w+)\s+#.+/)

first = m[1].to_i(16)
last = m[2]&.to_i(16) || first
type = m[3].to_sym
if !list.empty? and (list.last[:range].last + 1) == first and list.last[:type] == type
list.last[:range] = (list.last[:range].first..last)
else
Expand Down

0 comments on commit 7d2084b

Please sign in to comment.