lib/ting/conversions/hanyu.rb in ting-0.2.1 vs lib/ting/conversions/hanyu.rb in ting-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# coding: utf-8
+
module Ting
module Conversions
class Hanyu
def initialize(tone = :numbers, options = {})
@options = options
@@ -18,20 +20,20 @@
def valid_character_regexp!
valid_chars = []
Ting.valid_combinations do |i,f|
1.upto(5) do |tone|
- valid_chars += @tone.add_tone(Conversions.unparse(:hanyu,TonelessSyllable.new(i,f)), tone).chars
+ valid_chars += @tone.add_tone(Conversions.unparse(:hanyu,TonelessSyllable.new(i,f)), tone).uchars
end
end
valid_chars.sort!.uniq!
Regexp.new(valid_chars.map{|ch| Regexp.escape(ch)}.join('|'))
end
def parse(string)
result = []
looking_at = []
- string.chars.each do |ch|
+ string.uchars.each do |ch|
head, syll = parse_tail(looking_at)
looking_at << ch
if syll && !parse_tail(looking_at)
puts "-> #{syll.inspect}"
result << head.to_s unless head.empty?