hur.cn - 华软网

 热门搜索

如何取得汉字的拼音的首字母?

  作者:未知    来源:网络    更新时间:2017/12/5
我想取得输入的汉字的拼音的首字母,作为拼音代码,例如:输入“谢谢帮助”,程序就可以自动得出拼音代码“XXBZ”,这怎么实现呢?再次谢谢各位
------华软网友回答------
发消息给我,告诉我你的邮箱,我给你取汉字的第一个拼音字母的.PBL的例子,我现在在线。
------华软网友回复------
我先给你发一个全局函数:用来得到汉字的首字母。
string qsss,retstr
int qlen,hb,lb,i,h,l
QSSS=TRIM(hz)
QLEN=LEN(QSSS)
HB=176
LB=160
RETSTR=''
I=1
DO WHILE I<=QLEN
H=ASC(mid(QSSS,I,1))
//messagebox("",h)
if h<160 then
   retstr=retstr+char(h)
   i=i+1
else
L=ASC(mid(QSSS,I+1,1))
choose CASE h
CASE HB
IF L<=LB+36 then
RETSTR=RETSTR+'A'
ELSE
RETSTR=RETSTR+'B'
END If
CASE HB+1
RETSTR=RETSTR+'B'
CASE HB+2
IF L<=LB+32 then
RETSTR=RETSTR+'B'
ELSE
RETSTR=RETSTR+'C'
END If
CASE HB+3
RETSTR=RETSTR+'C'
CASE HB+4
IF L<=LB+77 then
RETSTR=RETSTR+'C'
ELSE
RETSTR=RETSTR+'D'
END If
CASE HB+5
RETSTR=RETSTR+'D'
CASE HB+6
IF L<=LB+73 then
RETSTR=RETSTR+'D'
ELSE
RETSTR=RETSTR+'E'
END If
CASE HB+7
IF L<=LB+1 then
RETSTR=RETSTR+'E'
ELSE
RETSTR=RETSTR+'F'
END If
CASE HB+8
IF L<=LB+32 then
RETSTR=RETSTR+'F'
ELSE
RETSTR=RETSTR+'G'
END If
CASE HB+9
IF L<=LB+93 then
RETSTR=RETSTR+'G'
ELSE
RETSTR=RETSTR+'H'
END If
CASE HB+10
RETSTR=RETSTR+'H'
CASE HB+11
IF L<=LB+86 then
RETSTR=RETSTR+'H'
ELSE
RETSTR=RETSTR+'J'
END If
CASE is <=HB+14
RETSTR=RETSTR+'J'
CASE HB+15
IF L<=LB+6 then
RETSTR=RETSTR+'J'
ELSE
RETSTR=RETSTR+'K'
END If 
CASE HB+16
IF L<=LB+11 then
RETSTR=RETSTR+'K'
ELSE
RETSTR=RETSTR+'L'
END If
CASE HB+17
RETSTR=RETSTR+'L'
CASE HB+18
IF L<=LB+71 then
RETSTR=RETSTR+'L'
ELSE
RETSTR=RETSTR+'M'
END If
CASE HB+19
RETSTR=RETSTR+'M'
CASE HB+20
IF L<=LB+34 then
RETSTR=RETSTR+'M'
ELSE
RETSTR=RETSTR+'N'
END If
CASE HB+21
IF L<=LB+21 then
RETSTR=RETSTR+'N'
ELSE
IF L<=LB+29 then
RETSTR=RETSTR+'O'
ELSE
RETSTR=RETSTR+'P'
END If
END If
CASE HB+22
IF L<=LB+57 then
RETSTR=RETSTR+'P'
ELSE
RETSTR=RETSTR+'Q'
END If
CASE HB+23
RETSTR=RETSTR+'Q'
CASE HB+24
IF L<=LB+26 then
RETSTR=RETSTR+'Q'
ELSE
IF L<=LB+85 then
RETSTR=RETSTR+'R'
ELSE
RETSTR=RETSTR+'S'
END If
END If
CASE is <=HB+26
RETSTR=RETSTR+'S'
CASE HB+27
IF L<=LB+88 then
RETSTR=RETSTR+'S'
ELSE
RETSTR=RETSTR+'T'
END If
CASE HB+28
RETSTR=RETSTR+'T'
CASE HB+29
IF L<=LB+57 then
RETSTR=RETSTR+'T'
ELSE
RETSTR=RETSTR+'W'
END If
CASE HB+30
IF L<=LB+83 then
RETSTR=RETSTR+'W'
ELSE
RETSTR=RETSTR+'X'
END If
CASE is <=HB+32
RETSTR=RETSTR+'X'
CASE HB+33
IF L<=LB+24 then
RETSTR=RETSTR+'X'
ELSE
RETSTR=RETSTR+'Y'
END If
CASE is <=HB+35
RETSTR=RETSTR+'Y'
CASE HB+36
IF L<=LB+48 then
RETSTR=RETSTR+'Y'
ELSE
RETSTR=RETSTR+'Z'
END If
CASE is <=HB+39
RETSTR=RETSTR+'Z'
case else
RETSTR=RETSTR+'%'
END Choose
I=I+2
end if
loop
RETUrn RETSTR

------华软网友回复------
我是用数据表的
把汉字和首字母存入一个表的
网上应该很多这种表的
------华软网友回复------
sunning0313@sohu.com
十分感谢!
------华软网友回复------
一般都是将汉字的拼音码存入数据库或txt文件,使用时查找就行了

------华软网友回复------
网上很多的啊...
------华软网友回复------
princelily(百合) ,谢谢!      
华软声明:本内容来自网络,如有侵犯您版权请来信指出,本站立即删除。