Serving your webpage as UTF-8

Yesterday, while after playing with the php.ini files etc to write my previous article i decided to play some more. This time to get my pages served with content-type UTF-8, which is a lot better then serving it as, by example, ISO-8859-1. I already knew this could be done by adding AddDefaultCharset utf-8 to your .htaccess file, but on my server this resulted in an internal server error. But since my ISP changed some of the settings on the server a few days ago (it now uses phpsuexec) i hoped it would work. Besides i leanerd that i could also try to use a php.ini file.

To test things i wrote 4 little testcases that should all display some special characters, that are just as plain text in the files (so whithout using character entities):

  • TestCase1: This page is served without any information about the character encoding so it uses the default of the browser. In Firefox this is ISO-8859-1, so you'll get some ugly characters instead of the nice word. In Opera UTF-8 is the default so you'll see the word as intended.
  • TestCase 2: This page is served as UTF-8 using a .htaccess file with the following statement: AddDefaultCharset utf-8
  • TestCase 3: This page is served as ISO-8859-1, to see the difference (this is also done using a .htaccess file)
  • TestCase 4: This page is served as UTF-8 but using a php.ini file:
default_charset = UTF-8

So as you can see in the testcases, the character encoding does mather if you want to use i18n. I also tried to set a default charset for my nucleus folder, but Nucleus sends pages as ISO-8859-1 (and adding the default charset doesn't change this)


There are no comments.

Comment Atom Feed