0

It seems that this question gets asked a lot, but I didn't find an answer that fits my setup and doen't ask me to convert my database.

Setup

I work in PHP, my db is latin_swedish_ci and the charset in the is utf-8.

I found a way to convert the db text to utf-8 using an homemade function that uses a mix of stripslashes() and utf8_encode(). I call it fxUnescape().

I also uses fxEscape() for MySQL purposes. It uses addslashes() and utf8_decode().

Problem

So here is my problem. When data is sent by a form, using fxEscape() breaks the accents and save them as ? in the database.

What do I do wrong?

p.s. To make things worse, Ihave a mix of iso-8859-1 and utf-8 encoded php files.

my posted data

Array
(
    [com_titre_billing] => m
    [com_prenom_billing] => Jean-Sébastien
    [com_nom_billing] => Proulx
    [pay_iso_billing] => CA
    [com_infolettre] => 1
    [btn_enregistrer] => Enregistrer
)

NEVERMIND: found the problem, there was an extra utf8_encode in the code

jesse94
  • 127
  • 1
  • 8
  • 2
    You want to be UTF8 all the way not ISO or latin1. http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – chris85 Mar 24 '15 at 21:33
  • What kind of language format does the document use? ANSI or UTF-8? Set your document to be UTF-8 without BOM. – faerin Mar 24 '15 at 21:35
  • "my db is latin_swedish_ci and the charset in the is utf-8" -- that's a contradiction. – Rick James Mar 24 '15 at 22:51
  • utf8_encode -- never needed. – Rick James Mar 24 '15 at 22:51
  • stripslashes -- never needed – Rick James Mar 24 '15 at 22:57
  • ok I added mysqlio charset to utf and the display is ok. But any form post is not utf8.The queries are handled in a string. Is that an issue? – jesse94 Mar 25 '15 at 13:53
  • my posted date looks like this: Array ( [com_titre_billing] => m [com_prenom_billing] => Jean-Sébastien [com_nom_billing] => Proulx [pay_iso_billing] => CA [com_infolettre] => 1 [btn_enregistrer] => Enregistrer ) – jesse94 Mar 25 '15 at 17:52

0 Answers0