Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character encoding for French Accents

I'm developing my first website for a French client and I'm having massive issues with accents being displayed as "?".After googling it for days, I thought I understood, but issues persists.

To simplify it, I'll explain just the email headers (the message contains french accents)

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

I've tried using charset UTF-8 and the iso-8859-1, but I still get this type of emails:

Merci pour votre intérêt pour les tee shirts. 

Can any one help? I'm having these issues with mySql, HTML, PHP everywhere basically.

Thanks.

like image 831
denislexic Avatar asked Apr 16 '11 22:04

denislexic


People also ask

What encoding do you use for French characters?

French Characters in HTML Documents - ISO-8859-1 Encoding. This section provides a tutorial example on how enter and use French characters in HTML documents using Unicode ISO-8859-1 encoding. The HTML document should include a meta tag with charset=ISO-8859-1 and be stored in ANSI format.

Can UTF-8 handle French characters?

UTF-8 supports any unicode character, which pragmatically means any natural language (Coptic, Sinhala, Phonecian, Cherokee etc), as well as many non-spoken languages (Music notation, mathematical symbols, APL).

Does UTF-8 include accents?

UTF-8 is a standard for representing Unicode numbers in computer files. Symbols with a Unicode number from 0 to 127 are represented exactly the same as in ASCII, using one 8-bit byte. This includes all Latin alphabet letters without accents.

How do you put French accents in HTML?

Example 1: To input the circumflex â (â) in HTML, type in â or â Exampe 2: To input circumflex ô (ô) in HTML, type in ô.


2 Answers

If intérêt shows up as intérêt you likely (i.e. short of corruption due to double encoding) have UTF-8 encoded text being shown up as if it were ISO-8859-1.

Make sure the headers are correctly formed and present the content as being UTF-8 encoded.

like image 171
Artefacto Avatar answered Oct 11 '22 10:10

Artefacto


First of all, make the charset in the header UTF8 again.

In your page, use utf8_encode() where appropriate to make sure values coming from a database or external files are properly encoded (try to set the encoding of the fields in your database to UTF8 as well)

Also, take a look at the htmlentities() function to parse special characters to html entities which may solve encoding issues as well.

like image 22
Wilbo Baggins Avatar answered Oct 11 '22 08:10

Wilbo Baggins