Search

The property HttpWebResponse.CharacterSet returns the wrong charset information. by Oleg Ufaev

Resolved
as By Design Help for as By Design

2
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 94051
Opened: 3/15/2006 10:50:56 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
If header Content-Type contains "text/" or "text/html" or "text/<something>", and does not contains charset information, then property HttpWebResponse.CharacterSet returns "ISO-8859-1" string.

It occurs because the method HttpWebResponse.CharacterSet contains following code:
...
string text1 = this.m_HttpResponseHeaders.ContentType;
...
string text2 = text1.ToLower(CultureInfo.InvariantCulture);
if (text2.Trim().StartsWith("text/"))
{
    this.m_CharacterSet = "ISO-8859-1";
}
...
while ((num1 = text2.IndexOf("charset", num1)) >= 0)
{
    ...
}

So, if header Content-Type does not contains charset information, "ISO-8859-1" will be returned, by default.

In .NET 1.1, in this case, returned String.Empty.
Details (expand)
Product Language
English
Version
Visual Studio 2005
Category
Base Class Libraries and APIs
Subcategory
 
Operating System
Windows XP Professional
Steps to Reproduce
-
Actual Results
"ISO-8859-1" string
Expected Results
String.Empty
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 3/21/2006 at 5:34 PM
Thank you for your feedback. This behavior is by design as documented by RFC 2616, section 3.7.1.