PHP Tutorials - Herong's Tutorial Examples - v5.16, by Herong Yang
Characters of Multiple Languages in HTML Documents
This section provides a tutorial example on how enter and use characters of multiple languages in a single HTML document with Unicode UTF-8 encoding.
After going through above examples, you should feel comfortable now on how to handle non-ASCII characters of any single language. You have a choice of using UTF-8 or a language specific encoding.
If you want to have characters of multiple languages in a single HTML document, then you have to use UTF-8 encoding. Here are the steps you can follow make a HTML document in UTF-8 to support multiple languages in a single HTML document.
1. On a Windows system, run Start > All Programs > Accessories > Notepad.
2. In Notepad, enter the following HTML document:
<html> <!-- HelloUtf8MultiLanguages.html #- Copyright 2009 (c) HerongYang.com. All Rights Reserved. --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <body> <b>Test</b><br/> English: Hello world!<br/> Spanish: ¡Hola mundo!<br/> Korean: 여보세요 세계 !<br/> Chinese: 你好世界!<br/> </body> </html>
3. Don't try to enter those hello messages yourself. Go to the Google language tool site, google.com/language_tools. You can enter "Hello world!" and translate it to other languages. On the translation output page, just copy those translations and paste them back to Notepad. This should cause no corruption, because Google site, Windows IE, and Notepad all support UTF-8.
4. Select menu File > Save as. Enter the file name as HelloUtf8MultiLanguages.html. Select "UTF-8" in the Encoding field and click the Save button.
5. Copy HelloUtf8MultiLanguages.html to c:\apache\htdocs. Make sure your Internet Information Service is running the local default Web site.
6. Now run Internet Explorer (IE) with http://localhost/HelloUtf8MultiLanguages.html. Your should see all characters displayed correctly.
7. On the IE window, select menu View > Encoding. You should see UTF-8 is selected.
Table of Contents