漢字轉(zhuǎn)拼音縮寫(xiě)的函數(shù)(VB),轉(zhuǎn)帶音調(diào)的可能有點(diǎn)。。。
十載的湘陰網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整湘陰建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“湘陰網(wǎng)站設(shè)計(jì)”,“湘陰網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
Public Function getPYChar(char As String) As String
Dim lChar As Long
lChar = 65536 + Asc(char)
If (lChar = 45217 And lChar = 45252) Then getPYChar = "A"
If (lChar = 45253 And lChar = 45760) Then getPYChar = "B"
If (lChar = 47761 And lChar = 46317) Then getPYChar = "C"
If (lChar = 46318 And lChar = 46825) Then getPYChar = "D"
If (lChar = 46826 And lChar = 47009) Then getPYChar = "E"
If (lChar = 47010 And lChar = 47296) Then getPYChar = "F"
If (lChar = 47297 And lChar = 47613) Then getPYChar = "G"
If (lChar = 47614 And lChar = 48118) Then getPYChar = "H"
If (lChar = 48119 And lChar = 49061) Then getPYChar = "J"
If (lChar = 49062 And lChar = 49323) Then getPYChar = "K"
If (lChar = 49324 And lChar = 49895) Then getPYChar = "L"
If (lChar = 49896 And lChar = 50370) Then getPYChar = "M"
If (lChar = 50371 And lChar = 50613) Then getPYChar = "N"
If (lChar = 50614 And lChar = 50621) Then getPYChar = "O"
If (lChar = 50622 And lChar = 50905) Then getPYChar = "P"
If (lChar = 50906 And lChar = 51386) Then getPYChar = "Q"
If (lChar = 51387 And lChar = 51445) Then getPYChar = "R"
If (lChar = 51446 And lChar = 52217) Then getPYChar = "S"
If (lChar = 52218 And lChar = 52697) Then getPYChar = "T"
If (lChar = 52698 And lChar = 52979) Then getPYChar = "W"
If (lChar = 52980 And lChar = 53640) Then getPYChar = "X"
If (lChar = 53689 And lChar = 54480) Then getPYChar = "Y"
If (lChar = 54481 And lChar = 52289) Then getPYChar = "Z"
End Function
Public Function getPY(str As String) As String
For i = 0 To Len(str) - 1
getPY = getPY getPYChar(Mid(str, i + 1, 1))
Next
End Function
360問(wèn)答
vb6.0怎樣實(shí)現(xiàn)漢字的拼音如text1輸入“拼音”就msgbox(pinyin)
lpnwk LV12
2013-07-01
滿意答案
husky0114
LV11
2013-07-02
我自己做了一個(gè)ocx'控件,可以輸入一大段中文后可輸出它的拼音,但前提是電腦可以聯(lián)網(wǎng) 調(diào)用方式 Private Sub Command1_Click() py1.輸入字符 = "你想要的文字" MsgBox py1.輸出字符 End Sub 控件下載地址我發(fā)給你,注意到百度信息里查收
建立一個(gè)表,每個(gè)拼音都跟多個(gè)漢字對(duì)應(yīng)。可以通過(guò)漢字,找出對(duì)應(yīng)的一個(gè)拼音,也可以通過(guò)拼音,找出一堆漢字。
原來(lái)還有這么個(gè)功能,那有沒(méi)有轉(zhuǎn)換為拼音的方法?
我比你運(yùn)氣好,兩個(gè)都有效:
Public?Class?Form1
Private?Declare?Function?LCMapString?Lib?"kernel32"?Alias?"LCMapStringA"?(ByVal?Locale?As?Integer,?ByVal?dwMapFlags?As?Integer,?ByVal?lpSrcStr?As?String,?ByVal?cchSrc?As?Integer,?ByVal?lpDestStr?As?String,?ByVal?cchDest?As?Integer)?As?Integer
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?cString?As?String?=?"中華人民共和國(guó)"
cString?=?(StrConv(cString,?VbStrConv.TraditionalChinese))
MsgBox(cString)
cString?=?(StrConv(cString,?VbStrConv.SimplifiedChinese))
MsgBox(cString)
Dim?rString?As?String?=?Space(14)
LCMapString(H804,?H4000000,?cString,?14,?rString,?14)
MsgBox(rString)
cString?=?rString
LCMapString(H804,?H2000000,?cString,?14,?rString,?14)
MsgBox(rString)
End?Sub
End?Class
StrConv參數(shù)不對(duì),api 函數(shù)Long型要改為Integer類型。
只能用數(shù)據(jù)庫(kù)的形式,如果你對(duì)GB2312編碼有研究的話,你會(huì)知道,它的碼表是按換漢語(yǔ)拼音來(lái)排的,這樣你做數(shù)據(jù)庫(kù)的時(shí)候可以參考GB2312的標(biāo)準(zhǔn),可以把數(shù)據(jù)庫(kù)設(shè)計(jì)得稍微簡(jiǎn)單那么一點(diǎn)點(diǎn)。
public string hz2py(string hz) //獲得漢字的區(qū)位碼
{
byte[] sarr = System.Text.Encoding.Default.GetBytes(hz);
int len = sarr.Length;
if (len1)
{
byte[] array = new byte[2];
array = System.Text.Encoding.Default.GetBytes(hz);
int i1 = (short)(array[0] - '\0');
int i2 = (short)(array[1] - '\0');
//unicode解碼方式下的漢字碼
// array = System.Text.Encoding.Unicode.GetBytes(hz);
// int i1 = (short)(array[0] - '\0');
// int i2 = (short)(array[1] - '\0');
// int t1 = Convert.ToInt32(i1,16);
// int t2 = Convert.ToInt32(i2,16);
int tmp=i1*256+i2;
string getpychar="*";//找不到拼音碼的用*補(bǔ)位
if(tmp=45217tmp=45252){getpychar= "A";}
else if(tmp=45253tmp=45760){getpychar= "B";}
else if(tmp=47761tmp=46317){getpychar= "C";}
else if(tmp=46318tmp=46825){getpychar= "D";}
else if(tmp=46826tmp=47009){getpychar= "E";}
else if(tmp=47010tmp=47296){getpychar= "F";}
else if(tmp=47297tmp=47613){getpychar= "G";}
else if(tmp=47614tmp=48118){getpychar= "H";}
else if(tmp=48119tmp=49061){getpychar= "J";}
else if(tmp=49062tmp=49323){getpychar= "K";}
else if(tmp=49324tmp=49895){getpychar= "L";}
else if(tmp=49896tmp=50370){getpychar= "M";}
else if(tmp=50371tmp=50613){getpychar= "N";}
else if(tmp=50614tmp=50621){getpychar= "O";}
else if(tmp=50622tmp=50905){getpychar= "P";}
else if(tmp=50906tmp=51386){getpychar= "Q";}
else if(tmp=51387tmp=51445){getpychar= "R";}
else if(tmp=51446tmp=52217){getpychar= "S";}
else if(tmp=52218tmp=52697){getpychar= "T";}
else if(tmp=52698tmp=52979){getpychar= "W";}
else if(tmp=52980tmp=53640){getpychar= "X";}
else if(tmp=53689tmp=54480){getpychar= "Y";}
else if(tmp=54481tmp=55289){getpychar= "Z";}
return getpychar;
}
else
{
return hz;
}
}
public string transpy(string strhz) //把漢字字符串轉(zhuǎn)換成拼音碼
{
string strtemp="";
int strlen=strhz.Length;
for (int i=0;i=strlen-1;i++)
{
strtemp+=hz2py(strhz.Substring(i,1));
}
return strtemp;
}
create table tabpy(id int identity,b_begin varbinary(2),b_end varbinary(2),word varchar(2))
insert tabpy select 0xB0A1, 0xB0C4,'A'
union all select 0xB0C5, 0xB2C0,'B'
union all select 0xB2C1, 0xB4ED,'C'
union all select 0xB4EE, 0xB6E9,'D'
union all select 0xB6EA, 0xB7A1,'E'
union all select 0xB7A2, 0xB8C0,'F'
union all select 0xB8C1, 0xB9FD,'G'
union all select 0xB9FE, 0xBBF6,'H'
union all select 0xBBF7, 0xBFA5,'J'
union all select 0xBFA6, 0xC0AB,'K'
union all select 0xC0AC, 0xC2E7,'L'
union all select 0xC2E8, 0xC4C2,'M'
union all select 0xC4C3, 0xC5B5,'N'
union all select 0xC5B6, 0xC5BD,'O'
union all select 0xC5BE, 0xC6D9,'P'
union all select 0xC6DA, 0xC8BA,'Q'
union all select 0xC8BB, 0xC8F5,'R'
union all select 0xC8F6, 0xCBF9,'S'
union all select 0xCBFA, 0xCDD9,'T'
union all select 0xCDDA, 0xCEF3,'W'
union all select 0xCEF4, 0xD1B8,'X'
union all select 0xD1B9, 0xD4D0,'Y'
union all select 0xD4D1, 0xD7F9,'Z'
函數(shù):
create function getfirstpy(@a varchar(200))
returns varchar(100)
as
begin
declare @i int,@j int,@result varchar(100)
set @result=''
set @i=len(@a)
set @j=1
while @j=@i
begin
select @result=@result+word from tabpy where cast(substring(@a,@j,1) as varbinary(2)) between b_begin and b_end
set @j=@j+1
end
return @result
end
名稱欄目:vb.net漢字轉(zhuǎn)全拼 漢字拼音互轉(zhuǎn)
URL標(biāo)題:http://jinyejixie.com/article10/dodhogo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、定制網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、云服務(wù)器、關(guān)鍵詞優(yōu)化、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)