Trying to get a simple insert saving data and the french characters are read back as box characters. How can I fix this?
$query = 'insert into category (category_en, category_fr) values
("Seamanship", "Matelotage"),
("General - Histoiry", "Généralités - Histoire")),
("Sailing", "Voile")';
When I display the results, I am seeing:
G�n�ralit�s � Histoire
I already noted that if I manually change these characters to be é
that I can save them correctly.
However this does not apply when saving directly from input fields in a form. All French characters in this case are being saved correctly.
I tried to apply SQLite3.escapestring
to the query above but it still failed.
Just wondering is there a more straight forward way instead of manually changing each character?
SOLUTION
utf8_encode() does the trick.
$query = utf8_encode('insert into category (category_en, category_fr) values
("Seamanship", "Matelotage"),
("General - Histoiry", "Généralités - Histoire")),
("Sailing", "Voile")';
Honestly when forms input fields save french characters correctly one would believe a hardcoded statement would be pretty logical. Hope this helps anyone looking for a quick solution.