Last active
February 6, 2022 13:09
Revisions
-
hpyhacking revised this gist
Jan 10, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,9 @@ cp = false def p(z) pinyin = Pinyin.t(z, '') pinyin[0] = pinyin[0].upcase pinyin end ARGF.readlines.each do |x| -
hpyhacking created this gist
Dec 16, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ require 'rubygems' require 'chinese_pinyin' name = [] cp = false def p(z) Pinyin.t(z, '') end ARGF.readlines.each do |x| if cp and (not (/X-PHONETIC/ =~ x)) if name and name.length == 2 puts "X-PHONETIC-FIRST-NAME:#{p(name[0])}" puts "X-PHONETIC-LAST-NAME:#{p(name[1])}" elsif name and name.length == 1 puts "X-PHONETIC-LAST-NAME:#{p(name[0])}" else raise "ERROR NAME FORMAT #{name}" end end cp = (/FN:/ =~ x) name = x.split(':')[1].split(' ') if cp puts x end