473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpWebResponse.CharacterSet

Why does HttpWebResponse.CharacterSet always return ISO-8859-1? I am
accessing a Chinese Web site (http://cn.yahoo.com) -- View Source in IE shows
the character set to be "gb2312", but the HttpWebResponse shows it to be
ISO-8859-1. Websites like www.cnn.com also show the character set to
ISO-8859-1

Here is the code snippet:

string pageAddress = "http://cn.yahoo.com";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Console.WriteLine(resp.CharacterSet);

Nov 17 '05 #1
1 3261
Jason Manfield wrote:
Why does HttpWebResponse.CharacterSet always return ISO-8859-1? I am
accessing a Chinese Web site (http://cn.yahoo.com) -- View Source in
IE shows the character set to be "gb2312", but the HttpWebResponse
shows it to be ISO-8859-1. Websites like www.cnn.com also show the
character set to ISO-8859-1

Here is the code snippet:

string pageAddress = "http://cn.yahoo.com";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Console.WriteLine(resp.CharacterSet);


HttpWebResponse needs to rely on HTTP headers to obtain such
information. Unfortunately, Google isn't really playing nice here and
uses HTML META tags to specify character encoding...

<meta http-equiv="content-type" content="text/html; charset=gb2312">

.... whereas the Content-Type header only says:

Content-Type: text/html

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2095
by: Denny Rue | last post by:
I’ve created VB code to download files from a web site through the use of HTTPWebRequest, HTTPWebResponse and BinaryReader. The HTTPWebRequest has a TimeOut property to limit how long it waits...
0
10279
by: hlabbott | last post by:
Hi I'm having a problem displaying attachments correctly. I have messages with attachments stored on Exchange2000 and want to be able to click a hyperlink in my project like in OWA and see an...
3
3307
by: Jaroslav Jakes | last post by:
Hi, I can't find out, how to detect the characterset of a text file. Orders I receive by mail have the same structure, but are created on different systems, like DOS, Windows, Linux. So the...
13
9780
by: Jason Manfield | last post by:
For some URLs (e.g.http://v3.espacenet.com/origdoc?DB=EPODOC&IDX=WO2005028634&F=0&QPN=WO2005028634), the content length for the HttpWebResponse I get with request.GetResponse in empty. The...
3
4647
by: Nuno Magalhaes | last post by:
Hello, In a simple thread I have a code like the one below: public void ProtectionRun() { while(true) { //Sleep thread for one minute //Thread.Sleep(60000); HttpWebRequest
2
2591
by: Noggin The Nog | last post by:
Hi all, I've been trying to get HttpWebResponse to work, but whenever I try I get "The operation has timed-out". I'm simply trying to send an HTTP request querystring to a remote website and read...
7
7401
by: Richard Bond | last post by:
Hi Is there anyway to change the characterset/codepage of a specific textbox on a winform. I have read in a "chinese traditional big5" file into memory using a streamreader with the...
2
2374
by: Nuno Magalhaes | last post by:
In pages that there is no content length, how does HttpWebResponse knows where the page ends? And what kind of objects/methods does it retrieve? Does it only retrieve the initial page without any...
6
6982
by: Leon_Amirreza | last post by:
My Page contains this: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i used this code to retrieve the page: HttpWebResponse webresp =...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.