PHP Tutorials - Herong's Tutorial Examples - Version 4.18, by Dr. Herong Yang
French Characters in HTML Documents - ISO-8859-1 Encoding
This section provides a tutorial example on how enter and use French characters PHP string literals using ISO-8859-1 encoding. The PHP script file should be stored in ANSI format.
Now we know how to make French characters working in a PHP string literal in UTF-8 encoding schema. Next let's see how to them working in ISO-8859-1 encoding schema.
1. On a Windows system, run Start > All Programs > Accessories > Notepad.
2. In Notepad, enter the following PHP script:
<?php #HelpIsoFrench.php #- Copyright (c) 2015, HerongYang.com, All Rights Reserved. # print('<html>'); print('<meta http-equiv="Content-Type"'. ' content="text/html; charset=iso-8859-1"/>'); print('<body>'); print('<b>Help</b><br/>'); print('English: System load is very high.<br/>'); print('French: L\'utilisation de système est très haute.<br/>'); print('</body>'); print('</html>'); ?>
3. To enter the French character, "e with grave", you can run Start > All Programs > System Tools > Character Map. Select "e with grave" on the character map. Click the Select button, then the Copy button. Go back to your Notepad and click Ctrl-V to paste "e with grave" into your PHP script.
4. Select menu File > Save as. Enter the file name as HelpIsoFrench.php. Select "ANSI" in the Encoding field and click the Save button. Note that ANSI is encoding schema defined by Microsoft and used on Windows system. ANSI contains more characters than ISO-8859-1. But it is compatible with ISO-8859-1.
5. Copy HelpIsoFrench.php to c:\inetpub\wwwroot. Make sure your Internet Information Service is running the local default Web site.
6. Now run Internet Explorer (IE) with http://localhost/HelpIsoFrench.php. Your should see the French characters displayed correctly as shown below:
Help English: System load is very high. French: L'utilisation de système est très haute.
7. On the IE window, select menu View > Encoding. You should see "Western European" is selected. Again "Western European" is a different name for ISO-8859-1.
Easy to do, right? We could make it even easier. You can remove the <meta> tag setting in HelpIsoFrench.html. French characters will still show up on the IE window. This is because ISO-8859-1 is the default encoding schema to IE.
Last update: 2015.
Table of Contents