Re: Encoding in ASP.NET sites

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thus wrote PL,

If you enter text directly onto the pages in UTF-8 then your pages
must be saved in UTF-8,

Yes and...

and you must specify the charset in the header
such as:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

No, you don't have to. The response encoding is set as charset attribute as part of the Content-Type HTTP header, which overrules META tags in every civilized browser in use (YMMV).

META tags are also completely useless for true multibyte encodings like UTF-16, at least as far as IE and Mozilla are concerned.

Although you don't necessarily have to save your scripts as UTF-8 to
display UTF-8, if you have unicode text being pulled from a database
then alll you need is to specify the default encoding for your app
which is usually already set to utf-8, you should also specify
CODEPAGE="65001" in your @ Page declaration as well as provide the
Content-Type meta tag so browsers know what encoding the page is in.

There's also the ResponseEncoding attribute, which uses friendly IANA names instead of Win32 codepage identifiers. And of course there's the ContentEncoding property in HttpResponse to set the encoding through code.

But all of this isn't required, *if* requestEncoding and responseEncoding are set to UTF-8 in web.config, which is the default.

Cheers,
--
Joerg Jooss
news-reply@xxxxxxxxxxxxx


.



Relevant Pages

  • Re: Print Spanish characters in Perl?
    ... and ensure that your file is saved in the UTF-8 format. ... encoding then your display device expects. ... forgetting to specify UTF-8 as charset. ... To avoid this kind of problem, make sure that all the characters are ...
    (comp.lang.perl.misc)
  • Re: Missing characters after file rewrite using File.OpenText
    ... you create your StreamReader. ... If your output file isn't meant to be UTF-8, you should specify the ... encoding when you create your StreamWriter. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Encoding in ASP.NET sites
    ... If you enter text directly onto the pages in UTF-8 then your pages must be ... and you must specify the charset in the header such as: ... It's the same in any encoding, the problem is that for some reason UTF-8 is ... Letters like ÆØÅ (norwegian letters) are displayed when I do it this ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Scraped content via WebRequest: Fixing mis-rendered characters systemically?
    ... I agree with Alexey here that you need to specify the encoding to read the ... response since it's by default using UTF-8. ... However, using 1252 will only work for ASCII encoding (for example, Western ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: automating the SQL warning and the choice of text format
    ... automatically select 'yes' and 'utf-8' rather than changing the registry, ... In order to get the correct encoding, I believe that you have to do the ... You need one of those for each data source. ... For a comma-delimited file using UTF-8 encoding, ...
    (microsoft.public.word.mailmerge.fields)