I am trying to save characters like "ą", "ć", "ł" but they are saved in the database as question marks (I save them using phpMyAdmin).
The database and table's collation is utf8_bin.
I am trying to save characters like "ą", "ć", "ł" but they are saved in the database as question marks (I save them using phpMyAdmin).
The database and table's collation is utf8_bin.
Try changing the collation to:
utf8_unicode_ci
or
utf8_polish_ci
You can refer to: http://mysql.rjweb.org/doc.php/charcoll
Also you can TRY altering the specific column with:
ALTER TABLE tbl MODIFY COLUMN txt TEXT CHARACTER SET utf8
You can also change column from vchar to nvchar. Then when inserting values to DB remember to ad N before as follows: N'ŁÓDŹ' (in persistence frameworks u should have some kind of NString representation)
from documentation:
Nvarchar stores UNICODE data. If you have requirements to store UNICODE or multilingual data, nvarchar is the choice. Varchar stores ASCII data and should be your data type of choice for normal use. Regarding memory usage, nvarchar uses 2 bytes per character, whereas varchar uses 1
I've searched a lot and finally, I got a solution with this:
ALTER TABLE tableName MODIFY COLUMN columnName VARCHAR(64) CHARACTER SET `binary`;
You can change VARCHAR(64)
to match your needs. I hope this helps someone. Note that I did not only required to store Polish characters but French and Spanish ones as well. So the solutions above might work for just polish chars.