编码问题
2008-01-08 09:56
337 查看
1.utf8转改变312
Dim utfinfo As String = Trim(WebBrowser1.DocumentText)
Dim gb2312info As String = String.Empty
Dim utf8 As Encoding = Encoding.UTF8
Dim gb2312 As Encoding = Encoding.GetEncoding("gb2312")
' Convert the string into a byte[].
Dim unicodeBytes As Byte() = utf8.GetBytes(utfinfo)
' Perform the conversion from one encoding to the other.
Dim asciiBytes As Byte() = Encoding.Convert(utf8, gb2312, unicodeBytes)
' Convert the new byte[] into a char[] and then into a string.
' This is a slightly different approach to converting to illustrate
' the use of GetCharCount/GetChars.
Dim asciiChars As Char() = New Char(gb2312.GetCharCount(asciiBytes, 0, asciiBytes.Length) - 1) {}
gb2312.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
gb2312info = New String(asciiChars)
原帖地址忘了
2.WebBrowser中解决中文乱码
Dim getReader As New System.IO.StreamReader(WebBrowser1.DocumentStream, System.Text.Encoding.GetEncoding("gb2312"))
Dim gethtml As String = getReader.ReadToEnd()
原帖地址:http://www.cnblogs.com/antsoftcn/archive/2006/12/27/604746.html
Dim utfinfo As String = Trim(WebBrowser1.DocumentText)
Dim gb2312info As String = String.Empty
Dim utf8 As Encoding = Encoding.UTF8
Dim gb2312 As Encoding = Encoding.GetEncoding("gb2312")
' Convert the string into a byte[].
Dim unicodeBytes As Byte() = utf8.GetBytes(utfinfo)
' Perform the conversion from one encoding to the other.
Dim asciiBytes As Byte() = Encoding.Convert(utf8, gb2312, unicodeBytes)
' Convert the new byte[] into a char[] and then into a string.
' This is a slightly different approach to converting to illustrate
' the use of GetCharCount/GetChars.
Dim asciiChars As Char() = New Char(gb2312.GetCharCount(asciiBytes, 0, asciiBytes.Length) - 1) {}
gb2312.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
gb2312info = New String(asciiChars)
原帖地址忘了
2.WebBrowser中解决中文乱码
Dim getReader As New System.IO.StreamReader(WebBrowser1.DocumentStream, System.Text.Encoding.GetEncoding("gb2312"))
Dim gethtml As String = getReader.ReadToEnd()
原帖地址:http://www.cnblogs.com/antsoftcn/archive/2006/12/27/604746.html
相关文章推荐
- 编码习惯——小错误大问题
- mysql 中文 变问号 编码问题
- 深入分析 Java 中的中文编码问题(键人岐)
- java中文乱码问题----java不同场景编码转换过程
- Java Web中的编码问题(一)
- Java字符的编码解码与乱码问题 Java字符的编码解码与乱码问题
- java web,charset编码设置正确情况下出现部分中文正常,部分中文乱码的问题
- java判断中文编码而后处理中文编码乱码问题
- java web,charset编码设置正确情况下出现部分中文正常,部分中文乱码的问题
- Python解决文件编码问题
- (透彻)java String.getBytes()编码问题
- HttpServletRequestWrapper Filter中装饰Request 解决全站编码问题!
- python编码问题
- 变分贝叶斯求解0.01范数稀疏编码问题
- 今天在Mac机器上使用了Flex Builder编辑了一个源代码文件,保存后使用vim命令去打开时发现系统自动在每一行的结尾添加了^M符号,其实^M在Linux/Unix中是非常常见的,也就是我们在Win中见过的/r回车符号。由于编辑软件的编码问题,某些IDE的编辑器在编辑完文件之后会自动加上这个^M符号。看起来对我们的源代码没有任何影响,其实并不然,当我们把源代码文件Check In到svn之类
- ajax提交中文编码问题(同时给出几个js与php编码方式)
- BlogEngine 1.0中的编码问题及解决方案
- String.getBytes()方法中的中文编码问题
- python的中文编码问题
- java 解决接口调用过程中的编码问题