Irfan Y
Irfan Y

Reputation: 1310

10.2.25-MariaDB not allowing data in multiple languages

Mysql version: 10.2.25-MariaDB

ENGINE=InnoDB

I'm trying to save data like: پہمغیابج ماوبرنم کرنامت

But it just shows question marks: ????

I have already tried:

Utf8, Utf8mb4 charset & utf8_general_ci, utf8_unicode_ci collation

but none of them seems to be working.

What charset or collation should I use to save data in multiple languages?

Update:

The same project is saving & retrieving data in multiple languages on my local machine (using mysql on local machine). But the server where I have deployed my code is using maria-db.

Update 2:

To make sure that its database issue and the client is sending correct data to db, I saved data to a text file just before saving it to database. The text file contains correct data but database has ??? in it.

Upvotes: 0

Views: 324

Answers (2)

Irfan Y
Irfan Y

Reputation: 1310

I added charset=utf8 in connectionstring and it worked.

Upvotes: 0

fifonik
fifonik

Reputation: 1606

SHOW VARIABLES LIKE 'character_set%'

Check character_set_database, character_set_connection and character_set_result.

Most probably the server default character set is not UTF-8 so you need to configure your connection manually by issuing SET NAMES UTF8 just after connection.

In php you can do the same using $connection->set_charset('UTF8')

Also you will need to check your tables character set (SHOW CREATE TABLE xyz). If your database character set was NOT set UTF8 and you created tables without character set specified per table/columns, the tables cannot hold the UTF8 characters and you will need to re-create them.

Upvotes: 1

Related Questions