Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unicode properties of East Asian Width #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions tool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PROP_FILES = \
$(UNICODE_VERSION)/PropList.txt \
$(UNICODE_VERSION)/Scripts.txt \
$(UNICODE_VERSION)/UnicodeData.txt \
$(UNICODE_VERSION)/EastAsianWidth.txt \
$(UNICODE_VERSION)/auxiliary/GraphemeBreakProperty.txt \
$(UNICODE_VERSION)/emoji-data.txt

Expand Down
2 changes: 1 addition & 1 deletion tool/download-ucd.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

files='Blocks.txt CaseFolding.txt DerivedAge.txt DerivedCoreProperties.txt PropertyAliases.txt PropertyValueAliases.txt PropList.txt Scripts.txt SpecialCasing.txt UnicodeData.txt auxiliary/GraphemeBreakProperty.txt'
files='Blocks.txt CaseFolding.txt DerivedAge.txt DerivedCoreProperties.txt PropertyAliases.txt PropertyValueAliases.txt PropList.txt Scripts.txt SpecialCasing.txt UnicodeData.txt EastAsianWidth.txt auxiliary/GraphemeBreakProperty.txt'
emoji_files='emoji-data.txt'

if [ -z $1 ] || [ -z $2 ]; then
Expand Down
26 changes: 26 additions & 0 deletions tool/enc-unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,31 @@ def parse_scripts(data, categories)
names.values.flatten << 'Unknown'
end

def parse_east_asian_width(data)
width_types = {}
aliases = {}
data_foreach('PropertyValueAliases.txt') do |line|
if /^ea\s*; (\w+)\s*; (\w+)(?:\s*; (\w+))?/ =~ line
aliases[$1] = $2
end
end
data_foreach('EastAsianWidth.txt') do |line|
if /^([0-9a-fA-F]+)(?:\.\.([0-9a-fA-F]+))?\s*;\s*(\w+)/ =~ line
type = aliases[$3]
width_types[type] ||= []
if $2
width_types[type].concat(($1.to_i(16)..$2.to_i(16)).to_a)
else
width_types[type].push($1.to_i(16))
end
end
end
width_types.each_pair do |type, cps|
data[type] = cps
end
width_types.keys
end

def parse_aliases(data)
kv = {}
data_foreach('PropertyAliases.txt') do |line|
Expand Down Expand Up @@ -398,6 +423,7 @@ def write(str)
props, data = parse_unicode_data(get_file('UnicodeData.txt'))
categories = {}
props.concat parse_scripts(data, categories)
props.concat parse_east_asian_width(data)
aliases = parse_aliases(data)
ages = blocks = graphemeBreaks = nil
define_posix_props(data)
Expand Down