Mobile app version of vmapp.org
Login or Join
Ann8826881

: Fixing french language characters - some OK some not I need to fix some pages on a friend website somebody did for him. It is a french-speaking website. Here is the code of the page showing

@Ann8826881

Posted in: #CharacterSet #ContentType #Language

I need to fix some pages on a friend website somebody did for him. It is a french-speaking website.

Here is the code of the page showing all OK characters, ...followed by the code of a non-OK showing caracter (weird caracters apperas for accents).

What should I fix so that every page will show OK french characters ?

Good reading pages code is (in this one I can write été and it looks great)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>


The non-ok code is (in this one I need to write &eacute; to look great)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>


Another non-ok reading page code is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

The meta tags in your HTML document are important, especially the charset=utf-8 part. However, they are not sufficient to ensure that the document gets displayed correctly. What matters is that the content type matches the character set that was used by the software that created the page.

That means that there isn't a single fix for every page on your site. For each page, you need to:


Discover what character set that page was created with
Set that character set in the meta tags, or convert it to the character set in the meta tags.


I put the text "in this one I can write été and it looks great" into a text file named french-a.txt and saved. My text editor saves files as ISO-8859-1 by default. Indeed I can use the file command that comes with Linux to verify this:

$ file french-a.txt
french-a.txt: ISO-8859 text


Now I can convert that file to UTF-8 using iconv and test the result with the file command:

$ iconv -f ISO-8859-1 -t UTF-8 french-a.txt > french-b.txt
$ file french*.txt
french-a.txt: ISO-8859 text
french-b.txt: UTF-8 Unicode text


Using the commands file and iconv you can correctly identify and convert each of your files to your preferred character set. I would recommend UTF-8 since it can represent all languages, whereas ISO-8859-1 is limited to Western European languages.

You could also do the same with many text editors. They will detect the character set when they open the file and you can have them save the file in a specific character set.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme