Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

context.Response.Charset = Encoding.UTF8.ToString();

I had used this in my code to set the Charset but IE did not like it. Any reason why?

context.Response.Charset = Encoding.UTF8.ToString();

I ended up having to set it to just context.Response.ContentType = "application/json;charset=utf-8" or context.Response.Charset = "utf-8"; instead. Not sure then what Encoding.UTF8.ToString(); would be utilized for if IE can't take it

like image 760
PositiveGuy Avatar asked Jul 08 '09 04:07

PositiveGuy


2 Answers

Context.Response.Charset = Encoding.UTF8.WebName;

Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.

like image 121
Alex Avatar answered Sep 19 '22 20:09

Alex


Encoding.UTF8.ToString();

doesn't return

"utf-8"

It returns

"System.Text.UTF8Encoding"

which is the name of the type that Encoding.UTF8 lives in.

The name of the type (or class definition) is always returned by Object.ToString() if there is no overriding method in the class (which is the case here).

like image 29
Robert Harvey Avatar answered Sep 20 '22 20:09

Robert Harvey