Skip to content

Instantly share code, notes, and snippets.

@iizukanao
Last active December 14, 2015 21:49
Show Gist options
  • Select an option

  • Save iizukanao/5154373 to your computer and use it in GitHub Desktop.

Select an option

Save iizukanao/5154373 to your computer and use it in GitHub Desktop.
Extract F and W ranges from EastAsianWidth.txt (http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt)
is_continuous = false
start_code = nil
last_code = nil
File.open("EastAsianWidth.txt").each do |line|
if !(/^\s*#/ =~ line) and !(/^\s*$/ =~ line)
if /^([^;]+);(\S+)/ =~ line
if $2.index 'W' or $2.index 'F'
if not is_continuous
start_code = $1
is_continuous = true
end
last_code = $1
elsif is_continuous
puts "#{start_code} ~ #{last_code}"
is_continuous = false
end
end
end
end
if is_continuous
puts "#{start_code} ~ #{last_code}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment