拼音转换问题?
本帖最后由 jinxi2007 于 2013-03-14 14:51:12 编辑 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
这段代码转换时,M会转换为L,“长”转换成Z
谁有好的代码,给一个
[解决办法]
试试:
<VFP返回汉字或字符串的全拼或简拼>
http://download.csdn.net/source/1440621
不过多音字确实比较麻烦。