资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net汉字拼音 vba汉字转拼音代码

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

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

成都创新互联公司主要从事成都网站建设、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务宝丰,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

{

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 要把 李世明 三个字转成拼音LI SHI MING 拼音与拼音有空格 请高手把发个源代码给我。谢谢

Private Declare Function icePub_dictionaryCodeTransfer Lib "icePubDll.dll" (ByVal strDictionaryFilename As String,ByVal strSrc As String,ByVal strCode As String) As Integer

Dim a2 As Integer

Dim strCode As String

strCode=Space(1024)

a2=icePub_dictionaryCodeTransfer("拼音字典.txt","李世明",strCode)

MsgBox strCode

拼音字典.txt内容如下

李世明LI SHI MING

张三ZHANG SAN

下载

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

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

急急急 关于vb拼音查找问题

呵呵,累死了,但还有一些字不能辨认,对照集到我的博客找

Default.aspx.vb-----------------------------------------------

Partial Class Code_拼音模糊查找_Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'这里可将数据库某字段列读取到ArrayList

Dim word As New ArrayList

word.Add("天安门")

word.Add("安琪儿")

word.Add("大前门")

word.Add("大灰狼")

Session("word") = word

End Sub

Protected Sub se_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles se.Click

Dim jianpin As String = strPing(words.Text) '获得简拼

jp.Text = jianpin

Dim word As ArrayList = Session("word")

Dim jieguo As String = ""

ListBox1.Items.Clear()

For i As Integer = 0 To word.Count - 1 Step 1

If strPing(word.Item(i)).ToString.ToUpper.IndexOfAny(jianpin.ToUpper) = 0 Then

ListBox1.Items.Add(word.Item(i).ToString)

End If

Next

End Sub

Public Function strPing(ByVal str As String) As String

Dim reStr As String = ""

For i As Integer = 0 To Len(str) - 1

reStr = reStr wordPing(Mid(str, i + 1, 1))

Next

Return reStr

End Function

Public Function wordPing(ByVal word As String) As String

'这个对比表只是一个大概,还不完善,对不少汉字不能识别

Dim myPing As Long = 65536 + Asc(word)

Select Case myPing

Case 45217 To 45252

Return "A"

Case 45253 To 45760

Return "B"

Case 45761 To 46317

Return "C"

Case 46318 To 46825

Return "D"

Case 46826 To 47009

Return "E"

Case 47010 To 47296

Return "F"

Case 47297 To 47613

Return "G"

Case 47614 To 48118

Return "H"

Case 48119 To 49061

Return "J"

Case 49062 To 49323

Return "K"

Case 49324 To 49895

Return "L"

Case 49896 To 50370

Return "M"

Case 50371 To 50613

Return "N"

Case 50906 To 51386

Return "O"

Case 50622 To 50905

Return "P"

Case 45217 To 45252

Return "Q"

Case 51387 To 51445

Return "R"

Case 51446 To 52217

Return "S"

Case 52218 To 52697

Return "T"

Case 52698 To 52979

Return "W"

Case 52980 To 53640

Return "X"

Case 53689 To 54480

Return "Y"

Case 54481 To 65536

Return "Z"

Case Else

'返回原字符

Return word

End Select

End Function

End Class

Default.aspx--------------------------------------------------

%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Code_拼音模糊查找_Default" %

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""

head runat="server"

title拼音模糊查找/title

/head

body

form id="form1" runat="server"

div

asp:TextBox ID="words" runat="server"/asp:TextBox

asp:Button ID="se" runat="server" Text="搜索" Width="83px" /

br /

br /

简拼asp:TextBox ID="jp" runat="server" Width="93px"/asp:TextBox

br /

br /

相关词组br /

br /

asp:ListBox ID="ListBox1" runat="server" Height="123px" Width="126px"/asp:ListBox

/div

/form

/body

/html


本文题目:vb.net汉字拼音 vba汉字转拼音代码
转载注明:http://www.cdkjz.cn/article/dojcppp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220