Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

confused over utf-8 encoding

0 views
Skip to first unread message

Steve

unread,
Dec 11, 2006, 1:14:29 AM12/11/06
to
I wish my aspx pages to be interpreted as UTF-8 by browsers.

Apart from setting the following in the web.config file:

<globalization fileEncoding="utf-8" requestEncoding="utf-8"
responseEncoding="utf-8" />

1. Do I also have to specify <meta http-equiv="Content-Type"
content="text/html; charset=utf-8"> in every aspx page?

2. Or also specify utf-8 in the page directive of every page?

In short, I am a bit worried that when I see the source of my generated
aspx pages I see no meta information regarding the encoding. Should I
also be adding this into every page or is it not necessary as long as
it's specified in web.config?

Laurent Bugnion

unread,
Dec 11, 2006, 4:19:03 AM12/11/06
to
Hi,

Steve wrote:
> I wish my aspx pages to be interpreted as UTF-8 by browsers.
>
> Apart from setting the following in the web.config file:
>
> <globalization fileEncoding="utf-8" requestEncoding="utf-8"
> responseEncoding="utf-8" />
>
> 1. Do I also have to specify <meta http-equiv="Content-Type"
> content="text/html; charset=utf-8"> in every aspx page?

It is not necessary. Setting the encoding in the configuration file adds
the specified information to the request. Using META is useful if you
don't have access to the request's header, but if you use server-side
code, it's better to use the request's header directly.

> 2. Or also specify utf-8 in the page directive of every page?

If you want the setting to be valid for each page in your application,
use the configuration file.

If you want to specify something different for a given page, use the
Page directive.

This is valid for every setting, not only encoding.

> In short, I am a bit worried that when I see the source of my generated
> aspx pages I see no meta information regarding the encoding. Should I
> also be adding this into every page or is it not necessary as long as
> it's specified in web.config?

To check that this is working, check "Auto-select" in View / Encoding in
IE. Then load your page. Then check what the browser uses in View /
Encoding. It should be UTF8 (which is not the default).

Also, you can use Fiddler to check the Request header.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Steve

unread,
Dec 11, 2006, 4:28:31 AM12/11/06
to
Merci beaucoup Laurent!

That really put my mind at rest.

Thanks, Steve.

Juan T. Llibre

unread,
Dec 11, 2006, 9:09:28 AM12/11/06
to
Adding to Laurent's correct on-target explanation, you should grab yourself
a copy of ieHTTPHeaders, which shows you all the HTTP headers
included in the page you're displaying.

http://www.blunck.se/iehttpheaders/iehttpheaders.html

It's free...and very useful to verify whether any header is included in any page.

You turn it on, or off, after you install it,
by selecting "View", "Explorer Bar", "ieHttpHeaders" in IE.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steve" <bah...@iranmania.com> wrote in message
news:1165829311.2...@73g2000cwn.googlegroups.com...

Steve

unread,
Dec 11, 2006, 11:33:29 PM12/11/06
to
Thanks for that Juan. Will install it now.

Steve

0 new messages