summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb')
-rw-r--r--Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb
index 3b966d45a40..d270767c1b8 100644
--- a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb
+++ b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb
@@ -1,18 +1,22 @@
# encoding: UTF-8
-require 'scanf'
-require 'byebug'
-
module TeX
module Hyphen
class Converter
+ def self.scan_line(line)
+ m = line.match /^(0x\h{2})\tU\+(\h{4})(?:\t(1?)(?:\t(\w+)))?$/
+ return nil unless m
+
+ return m[1].to_i(16), m[2].to_i(16).chr(Encoding::UTF_8), m[3].to_i, m[4]
+ end
+
def read(conversion)
@mapping = { }
File.read(conversion).each_line do |line|
next if line =~ /^#/
- eightbit, usv = line.scanf "0x%02X\tU+%04X"
- @mapping[eightbit] = usv.chr(Encoding::UTF_8)
+ eightbit, usv = Converter.scan_line line
+ @mapping[eightbit] = usv.chr
end
end
@@ -28,7 +32,6 @@ module TeX
if doconvert
puts (line.strip.each_byte.map do |byte|
- byebug unless @mapping[byte]
@mapping[byte]
end || '').join
end