网上基本上都是转换成UTF8格式的,这个转为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