vb.net转换拼音简码 vb语言翻译成中文
VB.NET中怎么实现 汉字转换拼音呢
建立一个表,每个拼音都跟多个汉字对应。可以通过汉字,找出对应的一个拼音,也可以通过拼音,找出一堆汉字。
站在用户的角度思考问题,与客户深入沟通,找到仪征网站设计与仪征网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站制作、网站建设、企业官网、英文网站、手机端网站、网站推广、主机域名、网站空间、企业邮箱。业务覆盖仪征地区。
请教大家,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);
gb2312>unicode>utf8, 以及逆转的方法'>VB.net 字符转换问题 字符(汉字、数字、字母、符号)>gb2312>unicode>utf8, 以及逆转的方法
字符编码转换吗?
1.字符与gb2312(gbk的子集):
Public Function GBKEncode(ByVal sInput As String) As String
Dim ret_GBKEncode As String = ""
Dim i As Integer
Dim startIndex As Integer = 0
Dim endIndex As Integer
Dim x() As Byte = System.Text.Encoding.Default.GetBytes(sInput) '字符以及字符串在vb2008中都是以unicode编码存储的
endIndex = x.Length - 1
For i = startIndex To endIndex
ret_GBKEncode = "%" Hex(x(i))
Next
Return ret_GBKEncode
End Function
'GBK解码
Public Function GBKDecode(ByVal sInput As String) As String
sInput = sInput.Replace("%", "")
Dim ret_GBKDecode As String = ""
Dim sLen As Integer = sInput.Length
Dim n As Integer = sLen \ 2
Dim sBytes(0 To n - 1) As Byte
'转化为字节码
For i As Integer = 1 To n
sBytes(i - 1) = CByte("H" sInput.Substring(2 * i - 2, 2))
Next
'将字节码转化为字符串
ret_GBKDecode = System.Text.Encoding.Default.GetString(sBytes)
Return ret_GBKDecode
End Function
2.Unicode字符串为UTF-8
Imports System.Text
Public Function StringAsUtf8Bytes(ByVal strData As String) As Byte()
Dim bytes() As Byte
bytes = Encoding.UTF8.GetBytes(strData)
Return bytes
End Function
'这里可以类推出好几种。
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.net转换拼音简码 vb语言翻译成中文
本文网址:http://cdiso.cn/article/dddegic.html