Frustrated with the output of French text from database

On my Debian machine, French texts are displaced properly when retrieving from the data, but the display of french words with accented letters would have crazy characters like avancée after updating the database. I do not have this issue on my local machine, which is a mac. This problem started happening when I deployed the site on the Debian. Would anyone help me solve this problem?

Best

3 Replies

You are probably using utf8 as input where latin1 was expected, and the result is that the input is being converted from latin1 (or iso-8859-1) to utf8 when no conversion at all was needed. If you are importing a MySQL dump, try adding –defaultcharacterset=utf8 option. Example:

cat dump.sql | mysql  whateveroptions  --default_character_set=utf8

BTW: Try this and you will see what happens when you convert text which is already utf8 from latin1 to utf8:

echo avancée | recode latin1.. | recode latin1.. | recode latin1..

Thanks a lot. That has solved the display from the database. However, it appears the whole system is behaving that way. How do you solve the fact that the system is not fully integrated to utf8?

You can start by configuring a locale which is appropriate for you:

dpkg-reconfigure locales

If you are from France, select "fr_FR.UTF-8 UTF-8".

Sometimes the problem is more "the charset is not declared properly" than "not everything is in utf8". For example, if you look at email headers, you will see lines like "Content-Type: text/plain; charset="iso-8859-1". By using this information, email clients know when and how charset conversions should be made, without making mandatory that everybody uses utf8.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct