189 8069 5689

关于vb.netutf8的信息

gb2312>unicode>utf8, 以及逆转的方法'>VB.net 字符转换问题 字符(汉字、数字、字母、符号)>gb2312>unicode>utf8, 以及逆转的方法

字符编码转换吗?

创新互联公司是一家专业提供盐边企业网站建设,专注与网站制作、成都做网站、H5建站、小程序制作等业务。10年已为盐边众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

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 如何将编码GB2312转成UTF8

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

说明:strData参数是GB2312字符串,函数返回UTF8字节数组

vb.net 将中文转UTF8的代码?谁有的帮帮我吧!

根本都不是你说的简单的UTF8编码问题,人家是加密计算,下面的是UTF8编码转化函数

Private Function convert_UTF8(ByVal str As String) As String

Dim byt() As Byte = System.Text.Encoding.GetEncoding("Gb2312").GetBytes(str)

Return System.Text.Encoding.UTF8.GetString(byt)

End Function

vb.net utf8乱码转中文

这个你不如给出测试用例,直接给你写还好些。给不出测试用例就无法验证写得正确与否。


文章题目:关于vb.netutf8的信息
网页地址:http://jkwzsj.com/article/doschec.html

其他资讯