The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'General Discussion' started by its_joe, Apr 16, 2007.

  1. its_joe

    its_joe Well-Known Member

    Joined:
    Feb 15, 2007
    Messages:
    134
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    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.
     
  3. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    Alternatively, add
    Code:
    init-connect=SET NAMES binary
    
    to /etc/my.cnf under [mysqld]

    That should fix the display problems.
     
  4. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
  5. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Be warned that the above advice causes problems with PHPMyAdmin.

    Edit:

    That is, the advice about init-connect
     
    #5 cPanelKenneth, Apr 19, 2007
    Last edited: Apr 19, 2007
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    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 :)
     
  7. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    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)
     
Loading...

Share This Page