|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Brief Version!thought my post is too long the short version is:
i have this tag in my HTML file served by IIS <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> IE show this page correctly but I need to detect the characterset of the response and HttpWebResponse webresp = (HttpWebResponse)(webrq.GetResponse()); ... console.WriteLine(webresp.CharacterSet); dumps this on screen ISO-8859-1 instead of utf-8 ! why? While making a request, add a "Accept-Charset" header with appropriate
values. An example may be: Accept-Charset: utf-8 See "Section 14" of RFC-2616. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html -- Show quoteHappy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- "Leon_Amirreza" <amirreza_rahm***@yahoo.com> wrote in message news:%23DuRsby3GHA.1060@TK2MSFTNGP04.phx.gbl... > thought my post is too long the short version is: > i have this tag in my HTML file served by IIS > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > > IE show this page correctly but I need to detect the characterset of the > response and > > HttpWebResponse webresp = (HttpWebResponse)(webrq.GetResponse()); > ... > console.WriteLine(webresp.CharacterSet); > > dumps this on screen > > ISO-8859-1 > > instead of utf-8 ! why? > > > Thanks for the useful link and comment.
Any way I can force the IIS to send the page in the charset I want when there is no accept-charset in the request header (something like default charset option in the server)? "Gaurav Vaish (www.EduJiniOnline.com)" <gaurav.vaish.nospam@nospam.gmail.com> wrote in message Show quote news:eLk$HG53GHA.4972@TK2MSFTNGP03.phx.gbl... > While making a request, add a "Accept-Charset" header with appropriate > values. > An example may be: > > Accept-Charset: utf-8 > > See "Section 14" of RFC-2616. > http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html > > > -- > Happy Hacking, > Gaurav Vaish | http://www.mastergaurav.com > http://www.edujinionline.com > http://articles.edujinionline.com/webservices > ------------------- > > > "Leon_Amirreza" <amirreza_rahm***@yahoo.com> wrote in message > news:%23DuRsby3GHA.1060@TK2MSFTNGP04.phx.gbl... >> thought my post is too long the short version is: >> i have this tag in my HTML file served by IIS >> >> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> >> >> IE show this page correctly but I need to detect the characterset of the >> response and >> >> HttpWebResponse webresp = >> (HttpWebResponse)(webrq.GetResponse()); >> ... >> console.WriteLine(webresp.CharacterSet); >> >> dumps this on screen >> >> ISO-8859-1 >> >> instead of utf-8 ! why? >> >> >> > > > Thanks for the useful link and comment. It's not the IIS that sends the charset.> Any way I can force the IIS to send the page in the charset I want when > there is no accept-charset in the request header (something like default > charset option in the server)? It's in the ASPX page itself. Add an attribute to the page directive. <%@ Page ContentType="text/html; charset=utf-8" ... %> -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- adding Accept-Charset: utf-8 didnt solve the problem:
webrq.Headers.Add(HttpRequestHeader.AcceptCharset, Encoding.UTF8.WebName); I dunno what is wrong with it? Show quote "Leon_Amirreza" <amirreza_rahm***@yahoo.com> wrote in message news:uuH26i63GHA.512@TK2MSFTNGP06.phx.gbl... > Thanks for the useful link and comment. > Any way I can force the IIS to send the page in the charset I want when > there is no accept-charset in the request header (something like default > charset option in the server)? > > > "Gaurav Vaish (www.EduJiniOnline.com)" > <gaurav.vaish.nospam@nospam.gmail.com> wrote in message > news:eLk$HG53GHA.4972@TK2MSFTNGP03.phx.gbl... >> While making a request, add a "Accept-Charset" header with appropriate >> values. >> An example may be: >> >> Accept-Charset: utf-8 >> >> See "Section 14" of RFC-2616. >> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html >> >> >> -- >> Happy Hacking, >> Gaurav Vaish | http://www.mastergaurav.com >> http://www.edujinionline.com >> http://articles.edujinionline.com/webservices >> ------------------- >> >> >> "Leon_Amirreza" <amirreza_rahm***@yahoo.com> wrote in message >> news:%23DuRsby3GHA.1060@TK2MSFTNGP04.phx.gbl... >>> thought my post is too long the short version is: >>> i have this tag in my HTML file served by IIS >>> >>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> >>> >>> IE show this page correctly but I need to detect the characterset of the >>> response and >>> >>> HttpWebResponse webresp = >>> (HttpWebResponse)(webrq.GetResponse()); >>> ... >>> console.WriteLine(webresp.CharacterSet); >>> >>> dumps this on screen >>> >>> ISO-8859-1 >>> >>> instead of utf-8 ! why? >>> >>> >>> >> >> > > |
|||||||||||||||||||||||