主题:[原创]疯狂的VFPER之获取汉字拼音简码
一晃真正用VFP写程序也已6年多了,大大小小也做了几十个系统,曾经有多少个日夜坐在电脑前敲打着空格、回车...,突然发现我在论坛上回贴的多,发贴的少,决定痛改前非:)...闲话少说,言归正传,我会陆续将我的部份VFP代码给大家分享(并不一定都是我的原创,有些是在其他VFPER的代码上改的)。
疯狂的VFPER之获取汉字拼音简码
Procedure pinyin
Parameter tcString
Private lcCode,i,j,lcChina,lcChar,lcPinyin
Local lcCode,i,j,lcChina,lcChar,lcPinyin
lcPinyin = ""
lcCode = "八嚓咑妸发旮铪讥讥咔垃呣拿讴趴七呥仨他哇哇哇夕丫匝咗" &&从b开始的每个拼音码的首字符
For i=1 To Len(tcString)
If Asc(Substr(tcString,i,1))>160 &&判断是否为汉字
lcChina = Substr(tcString,i,2)
lcChar = ""
For j=1 To 26
If Substrc(lcChina,1,1)<Substrc(lcCode,j,1) &&进行汉字比较
lcChar = Chr(96+j) &&得到首位拼音码
Exit
Endif
Endfor
lcPinyin = lcPinyin + Upper(lcChar)
i = i+1
Else
lcPinyin = lcPinyin + Upper(Substr(tcString,i,1))
Endif
Endfor
Return lcPinyin
Endproc
疯狂的VFPER之获取汉字拼音简码
Procedure pinyin
Parameter tcString
Private lcCode,i,j,lcChina,lcChar,lcPinyin
Local lcCode,i,j,lcChina,lcChar,lcPinyin
lcPinyin = ""
lcCode = "八嚓咑妸发旮铪讥讥咔垃呣拿讴趴七呥仨他哇哇哇夕丫匝咗" &&从b开始的每个拼音码的首字符
For i=1 To Len(tcString)
If Asc(Substr(tcString,i,1))>160 &&判断是否为汉字
lcChina = Substr(tcString,i,2)
lcChar = ""
For j=1 To 26
If Substrc(lcChina,1,1)<Substrc(lcCode,j,1) &&进行汉字比较
lcChar = Chr(96+j) &&得到首位拼音码
Exit
Endif
Endfor
lcPinyin = lcPinyin + Upper(lcChar)
i = i+1
Else
lcPinyin = lcPinyin + Upper(Substr(tcString,i,1))
Endif
Endfor
Return lcPinyin
Endproc