vb.net汉字转全拼 汉字拼音互转

vb 汉字转拼音

汉字转拼音缩写的函数(VB),转带音调的可能有点。。。

十载的湘阴网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整湘阴建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“湘阴网站设计”,“湘阴网站推广”以来,每个客户项目都认真落实执行。

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

用vb如何实现将汉字转换成拼音

360问答

vb6.0怎样实现汉字的拼音如text1输入“拼音”就msgbox(pinyin)

lpnwk LV12

2013-07-01

满意答案

husky0114

LV11

2013-07-02

我自己做了一个ocx'控件,可以输入一大段中文后可输出它的拼音,但前提是电脑可以联网 调用方式 Private Sub Command1_Click() py1.输入字符 = "你想要的文字" MsgBox py1.输出字符 End Sub 控件下载地址我发给你,注意到百度信息里查收

VB.NET中怎么实现 汉字转换拼音呢

建立一个表,每个拼音都跟多个汉字对应。可以通过汉字,找出对应的一个拼音,也可以通过拼音,找出一堆汉字。

vb.net 2008 如何将简体中文跟繁体中文互转呢?

原来还有这么个功能,那有没有转换为拼音的方法?

我比你运气好,两个都有效:

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 = "中华人民共和国"

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参数不对,api 函数Long型要改为Integer类型。

在vb中怎样实现汉字和拼音的转换

只能用数据库的形式,如果你对GB2312编码有研究的话,你会知道,它的码表是按换汉语拼音来排的,这样你做数据库的时候可以参考GB2312的标准,可以把数据库设计得稍微简单那么一点点。

如何用vb.net将汉字转换成拼音阿

public string hz2py(string hz) //获得汉字的区位码

{

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="*";//找不到拼音码的用*补位

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) //把汉字字符串转换成拼音码

{

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'

函数:

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汉字转全拼 汉字拼音互转
转载源于:http://azwzsj.com/article/dodhogo.html