x*g 发帖数: 689 | 1 在一个.net 2.0的winform程序里面,
我用webbrowser control去连一个网页,然后
用DocumentText propery得到网页内容,可是所有的
中文内容都变成乱麻了(问号之类的)。请问
如何解决? .net应该是支持unicode的呀? |
c**t 发帖数: 2744 | 2 能post你的code? 你确信encoding设置对了?
【在 x*g 的大作中提到】 : 在一个.net 2.0的winform程序里面, : 我用webbrowser control去连一个网页,然后 : 用DocumentText propery得到网页内容,可是所有的 : 中文内容都变成乱麻了(问号之类的)。请问 : 如何解决? .net应该是支持unicode的呀?
|
x*g 发帖数: 689 | 3 我没有设置encoding,
string txt = webbrowser1.DocumentText;
如何设置?
【在 c**t 的大作中提到】 : 能post你的code? 你确信encoding设置对了?
|
c**t 发帖数: 2744 | 4 FYI: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
【在 x*g 的大作中提到】 : 我没有设置encoding, : string txt = webbrowser1.DocumentText; : 如何设置?
|
x*g 发帖数: 689 | 5 thanks.Your reference link is using the webrequest and
webresponse class.
My program is using the webbrowser control. I googled for
sometime but still can't find how to retrieve unicode(Chinese)
correctly...
【在 c**t 的大作中提到】 : FYI: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
|
c**t 发帖数: 2744 | 6 did you try to modify the html header? and have you set the Regional and
Language Options?
【在 x*g 的大作中提到】 : thanks.Your reference link is using the webrequest and : webresponse class. : My program is using the webbrowser control. I googled for : sometime but still can't find how to retrieve unicode(Chinese) : correctly...
|
x*g 发帖数: 689 | 7 No, I didn't modify anything in html header.
defaul Regional and Language Options is set to Chinese.
in the control all chinese display correct, but when
I tried to get the text, they are all messed up.
【在 c**t 的大作中提到】 : did you try to modify the html header? and have you set the Regional and : Language Options?
|
c**t 发帖数: 2744 | 8 中文是双字节,在用BinaryReader的时候加上encoding 参数试
一试
【在 x*g 的大作中提到】 : No, I didn't modify anything in html header. : defaul Regional and Language Options is set to Chinese. : in the control all chinese display correct, but when : I tried to get the text, they are all messed up.
|
a9 发帖数: 21638 | 9 Encoding.Convert一下试试看。
【在 c**t 的大作中提到】 : 中文是双字节,在用BinaryReader的时候加上encoding 参数试 : 一试
|
l*s 发帖数: 783 | 10 Here is code I used b4. There are different encodings for chinese character
so you need to figure it out.
private string GBToUnicode(Encoding SrcEncoding, Encoding
DstEncoding, string oString)
{
byte[] unicodeBytes;
char[] unicodeChars;
string unicdoeString;
unicodeBytes = Encoding.Convert(SrcEncoding, DstEncoding,
SrcEncoding.GetBytes(oString));
unicodeChars = new char[DstEncoding.GetCharCount(unicodeBytes, 0
, unicodeB
【在 c**t 的大作中提到】 : 中文是双字节,在用BinaryReader的时候加上encoding 参数试 : 一试
|