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

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

vbnet改變字符集 vbnet 字典

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

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

成都創(chuàng)新互聯(lián)公司溝通電話:028-86922220,為您提供成都網(wǎng)站建設(shè)網(wǎng)頁設(shè)計(jì)及定制高端網(wǎng)站建設(shè)服務(wù),成都創(chuàng)新互聯(lián)公司網(wǎng)頁制作領(lǐng)域10多年,包括成都衛(wèi)生間隔斷等多個(gè)行業(yè)擁有多年建站經(jīng)驗(yàn),選擇成都創(chuàng)新互聯(lián)公司,為企業(yè)錦上添花。

'GBK編碼(結(jié)果以百分號(hào)%進(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中都是以u(píng)nicode編碼存儲(chǔ)的

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 如何將編碼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 以下代碼,在取中文文件名時(shí)出亂碼,怎么辦?請(qǐng)教.

沒有指定字符集,根據(jù)頁面的設(shè)置,可以設(shè)置字符集為UTF-8或GB2312

vb.Net對(duì)文件指定字符串的修改

文本框 TextBox1

上一條 Button1

下一條 Button2

修改 Button3

Imports?System.IO

Public?Class?Form1

Dim?currIndex?As?Integer?=?0

Dim?s2?As?List(Of?String)?=?New?List(Of?String)

Dim?s?As?String

Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load

s?=?File.ReadAllText(Application.StartupPath??"\txt.txt")

Dim?s1?As?String()?=?s.Split("@")

For?i?As?Integer?=?0?To?s1.Length?-?1

If?s1(i).Trim()??""?Then

s2.Add("@"??s1(i))

End?If

Next

TextBox1.Text?=?s2(0)

End?Sub

Private?Sub?Button2_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button2.Click

currIndex?=?currIndex?+?1

If?currIndex??s2.Count?-?1?Then

MsgBox("已經(jīng)是最后條了")

Return

End?If

TextBox1.Text?=?s2(currIndex)

End?Sub

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click

currIndex?=?currIndex?-?1

If?currIndex??0?Then

MsgBox("已經(jīng)是第一條了")

Return

End?If

TextBox1.Text?=?s2(currIndex)

End?Sub

Private?Sub?Button3_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button3.Click

s2(currIndex)?=?TextBox1.Text

s?=?""

For?i?As?Integer?=?0?To?s2.Count?-?1

s?=?s2(i)

Next

File.WriteAllText(Application.StartupPath??"\txt.txt",?s)

End?Sub

End?Class

gb2312>unicode>utf8, 以及逆轉(zhuǎn)的方法'>VB.net 字符轉(zhuǎn)換問題 字符(漢字、數(shù)字、字母、符號(hào))>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中都是以u(píng)nicode編碼存儲(chǔ)的

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

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


本文標(biāo)題:vbnet改變字符集 vbnet 字典
URL地址:http://weahome.cn/article/hpeejg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部