开发者

Encoding Of An Asp.net Web Page - Possible Ways - Deifference - web.config (Globalization) vs. Meta Tag vs. etc

What are the possible ways to encode an Asp.net Web Page?

What is the difference between web.config (Globalization) in the link below:

How to: Select an Encoding for ASP.NET Web Page Globalization

And a meta tag like below:

http://www.w3schools.com/tags/att_meta_http_eq开发者_运维知识库uiv.asp

(also we can select encoding on every page in PAGE DIRECTIVE, so what is the difference between that and the <meta> http-equiv attribute?)


The encoding you set in web.config allows you to configure the encoding that pages should be sent in.

The encoding you set in a Page directive allows you to override the web.config setting for individual pages (Word of advise - don't use it).

The encoding you set in the META tags or the response headers (ASP .NET will set response headers automagically for you); is a helpful hint to the browser about which encoding the page is sent in, so that it can decode it correctly.

In other words, the encoding in web.config, headers and in meta-tags should be set to the same encoding for things to work properly. UTF-8 is a good choice - it handles most (western european, at least) international chaaracters, and it is single byte per character unless the character is above codepoint 128 (in other words, english text is the same size in UTF8 and ASCII - so no excuse for sticking with ASCII !).

Link to the obligatory article about encodings - if you haven't yet, read it. It will save you some grief in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜