真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net文字轉(zhuǎn)編碼,vbs編碼轉(zhuǎn)換

vb.net怎么把漢字轉(zhuǎn)換為GB2312編碼,例如“武漢”變成%CE%E4%BA%BA。希望那位好人能解,最好詳細(xì)點,,,

這是HtmlEncode 不是GB2312編碼~

創(chuàng)新互聯(lián)建站一直通過網(wǎng)站建設(shè)和網(wǎng)站營銷幫助企業(yè)獲得更多客戶資源。 以"深度挖掘,量身打造,注重實效"的一站式服務(wù),以成都網(wǎng)站制作、網(wǎng)站建設(shè)、移動互聯(lián)產(chǎn)品、全網(wǎng)整合營銷推廣服務(wù)為核心業(yè)務(wù)。10年網(wǎng)站制作的經(jīng)驗,使用新網(wǎng)站建設(shè)技術(shù),全新開發(fā)出的標(biāo)準(zhǔn)網(wǎng)站,不但價格便宜而且實用、靈活,特別適合中小公司網(wǎng)站制作。網(wǎng)站管理系統(tǒng)簡單易用,維護(hù)方便,您可以完全操作網(wǎng)站資料,是中小公司快速網(wǎng)站建設(shè)的選擇。

一般用于URL傳遞

System.Web.HttpUtility.HtmlEncode(“武漢”)

System.WebHttpUtility.HtmlDecode(“%CE%E4%BA%BA”)

vb.net 如何將編碼GB2312轉(zhuǎn)成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參數(shù)是GB2312字符串,函數(shù)返回UTF8字節(jié)數(shù)組

vb.net怎么把漢字轉(zhuǎn)換為GB2312編碼,例如“廣東”變成%B9%E3%B6%AB

GB2312是GBK編碼的子集,使用GBK編碼函數(shù)即可

'GBK編碼(結(jié)果以百分號%進(jìn)行分隔)

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

'轉(zhuǎn)化為字節(jié)碼

For i As Integer = 1 To n

sBytes(i - 1) = CByte("H" sInput.Substring(2 * i - 2, 2))

Next

'將字節(jié)碼轉(zhuǎn)化為字符串

ret_GBKDecode = System.Text.Encoding.Default.GetString(sBytes)

Return ret_GBKDecode

End Function

vb.net中string 轉(zhuǎn) unicode 編碼

Unicode編碼是一個數(shù)組,其中每個元素代表一個位碼,還有ASCII和UTF8兩種編碼格式。

Unicode:

Dim bytes() As Byte() = System.Text.Encoding.Unicode.GetBytes("字符串")

ASCII:

Dim bytes() As Byte() = System.Text.Encoding.ASCII.GetBytes("字符串")

UTF8:

Dim bytes() As Byte() = System.Text.Encoding.UTF8.GetBytes("字符串")

gb2312>unicode>utf8, 以及逆轉(zhuǎn)的方法'>VB.net 字符轉(zhuǎn)換問題 字符(漢字、數(shù)字、字母、符號)>gb2312>unicode>utf8, 以及逆轉(zhuǎn)的方法

字符編碼轉(zhuǎn)換嗎?

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

'轉(zhuǎn)化為字節(jié)碼

For i As Integer = 1 To n

sBytes(i - 1) = CByte("H" sInput.Substring(2 * i - 2, 2))

Next

'將字節(jié)碼轉(zhuǎn)化為字符串

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

'這里可以類推出好幾種。


網(wǎng)站名稱:vb.net文字轉(zhuǎn)編碼,vbs編碼轉(zhuǎn)換
轉(zhuǎn)載來于:http://weahome.cn/article/hdoico.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部