Whcih character ste to set for Persian/Arabix/Fharsi language

its_joe

Well-Known Member
Feb 15, 2007
134
0
166
Hello,

We have one database but it is showing ??? ??? marks.

Client of the database is saying that he is inserting arabic / Persian / Farsi characters in the database.

So what is the appropriate collision can be set for the database so that the error is solved and we don't see ???? ???? for the page.

Thank You.

its_joe
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
79
458
cPanel Access Level
Root Administrator
The data is being transformed by MySQL into the latin1 character set, which is the default if nothing is explicitly set. First thing to do is verify the data in the database is still in Arabic/Farsi. If it is, then you need do somethign like:

Code:
ALTER TABLE `tbl_name` CHARACTER SET utf-8;
Make certain the database is fully backed up before doing this.

Verifying the data is correect before doign the conversion can be annoying, especially since PHPMyAdmin the the CLI mysql client will both transform any result set into the default character set used for the connection, which again is usually latin1. Youn can find a lot of information regarding this in the MySQL manual.
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
Alternatively, add
Code:
init-connect=SET NAMES binary
to /etc/my.cnf under [mysqld]

That should fix the display problems.
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
79
458
cPanel Access Level
Root Administrator
Be warned that the above advice causes problems with PHPMyAdmin.

Edit:

That is, the advice about init-connect
 
Last edited:

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Agreed, usually these issues are more a matter of using the correct character set than anything. Having worked on Greek-language websites myself, I can identify with the complete headache that is getting everything on the correct character set.

UTF-8 is your friend :)

If things check out with the database, and the site is still showing question marks, change the coding of the page to UTF-8. Also wouldn't hurt to download the page into a text editor and in Save-As, select UTF-8 as the character encoding, so everything matches :)
 

casey

Well-Known Member
Jan 17, 2003
2,288
0
191
Be warned that the above advice causes problems with PHPMyAdmin.

Edit:

That is, the advice about init-connect
But it fixes the problem with the website without any worries about corrupting data. ;) It is, of course, the quick solution. The ultimate solution as touched on by DavidG is mentioned in the referenced thread. For easier reference it is:

mysqldump -uUSER -pPASSWORD database > database.sql
replace 'old charset' 'newcharset' -- database.sql
mysql -uUSER -pPASSWORD database < database.sql

(mysqldump should be set to "default-character-set=binary" in /etc/my.cnf before doing the above)