Emails template data with strange characters

Hi!!
I have emails template with strange characters in the subject and message body in PT and ES language. an example : Subject:Livro para Revisão: Livro Atribuído.

Any sugestion?
Thank you

Hi @nuno,

This is a problem with your database encoding. Have you recently changed your config.inc.php, or moved servers, or upgraded your installation?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi asmecher,

Yes, upgrade 2.4.2.0 to 2.4.7.1 (where everything was working fine) but the text of emails template data are with strange characters in the subject and message body in PT and ES language.
My solution was correcting the database of email_template_data one by one in the language PT.

Thank you asmecher.

Hi @nuno,

Did you double-check that your config.inc.php database parameters are the same as in your old installation?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

yes, the database parameters are the same.

Regards,

NP

Hi @nuno,

Can you post those settings here? Specifically, connection_charset, database_charset, and charset_normalization. Recommended values are in this thread:

Check using your browser’s “View Page Info” tool to see that the page is in the UTF-8 encoding. If you’ve inadvertently added whitespace to the header template or something similar, even though the page will specify UTF-8, the browser will interpret it as Latin1 or similar.

If you did a database dump and reload, it’s possible that the encoding got garbled there; on some versions of MySQL it’s necessary to specify --default-character-set=utf8 to mysqldump.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,
client_charset = utf-8, connection_charset = utf8, database_charset = Off, charset_normalization = On

Regards,

NP

Hi @nuno,

Ideally the database_charset should also be utf8, and you can turn charset_normalization off. Did you check the “view page info”?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

Where I check the “view page info”?

Thanks again,

NP

Hi @nuno,

That depends on your browser. For me, using Firefox, I can right-click on the page and select “View Page Info” from the menu. There, you should see “Encoding: UTF-8”.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

Yes the “View Page Info” is “Encoding: UTF-8”.

Regards,
NP

Hi @nuno,

It sounds like your database settings are OK, but I suspect your data itself is in the wrong encoding. This can happen when moving data between differently-configured MySQL databases, etc.

To fix this, the best thing to do is to dump your database to a file and run the file through a tool like iconv to convert the character encodings. Look for some content within the database dump that you can check on the output to make sure that it’s properly encoded.

Unfortunately once you’ve mixed content in different encodings (e.g. copying email templates one by one), it’s hard to fix this.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,

Ok, thanks again.

Regards,
NP