Skip to content

Commit

Permalink
Handle characters which are not Simplified Chinese properly
Browse files Browse the repository at this point in the history
  • Loading branch information
toritaba committed Jun 21, 2010
1 parent 1a0ee37 commit a0b7dee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/string_to_pinyin.rb
Expand Up @@ -13,7 +13,7 @@ def to_pinyin
if h[char]
result = result + h[char] + " "
else
result = result + self + " "
result = result + char
end
end
return result.rstrip
Expand Down
5 changes: 5 additions & 0 deletions spec/string_to_pinyin_spec.rb
Expand Up @@ -6,6 +6,7 @@
@single_char = "名"
@multiple_chars = "中华人民共和国"
@nil_char = "a"
@punctuated = "你好! 你是中国人吗? <- that was mandarin"
end

it "should return pinyin for a single character if found" do
Expand All @@ -19,4 +20,8 @@
it "should return a character if its not found in the index" do
@nil_char.to_pinyin.should == 'a'
end

it "should return 'non-simplified chinese characters' as they are" do
@punctuated.to_pinyin.should == 'nĭ hăo ! nĭ shì zhōng guó rén ma ? <- that was mandarin'
end
end

0 comments on commit a0b7dee

Please sign in to comment.