toPinyin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/test.rb +5 -0
- data/lib/toPinyin/version.rb +1 -1
- data/lib/toPinyin.rb +7 -1
- metadata +3 -3
data/lib/test.rb
CHANGED
@@ -8,6 +8,11 @@ raise "toPinyin faild" if s.pinyin != ["chun", "hua", "qiu", "yue", "he", "shi",
|
|
8
8
|
raise "toUnicode failed" if s.unicode != ["6625", "82B1", "79CB", "6708", "4F55", "65F6", "4E86"]
|
9
9
|
|
10
10
|
|
11
|
+
#should return nil
|
12
|
+
puts "test".unicode.inspect
|
13
|
+
puts "test".utf8.inspect
|
14
|
+
raise "fail to convert english words" if "test".pinyin != ["t","e","s","t"]
|
15
|
+
|
11
16
|
#let's sort it
|
12
17
|
|
13
18
|
words = "
|
data/lib/toPinyin/version.rb
CHANGED
data/lib/toPinyin.rb
CHANGED
@@ -46,7 +46,13 @@ def pinyin
|
|
46
46
|
#conver to unicode
|
47
47
|
#u = Iconv.iconv("UNICODEBIG","utf-8",c)[0].each_byte.map {|b| b.to_s(16)}.join
|
48
48
|
u=sprintf("%04X", c.unpack("U*").first)
|
49
|
-
|
49
|
+
#handle a-z, A-Z
|
50
|
+
if u =~ /^00/
|
51
|
+
#return c as it is
|
52
|
+
c
|
53
|
+
else
|
54
|
+
uniToPyMap[u.upcase].chop unless uniToPyMap[u.upcase].nil?
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toPinyin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- pierr.chen
|