Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    1

    Unanswered: Character Set Issue UTF-8, MySQL and Arabic

    I've got a character set issue with MySQL and Arabic.

    All my PHP pages have the header set to 'utf-8'.

    The content fields in my admin CMS pages appear to be saving the content correctly. (i.e the Arabic can be entered correctly and appears correctly when returning to that edit page). If I view source, I can see the Arabic lettering and not any special characters like html entities etc.

    When I look at what get's saved in the database via phpmyadmin I see a character set displayed which has no meaning to me:

    نتب نتنتس بنستبي ب

    When I see what's appearing on the front end pages (coming out directly from the database after it's been saved) I get another character set of equally little meaning to me but slightly different:

    �بت ب�ت�س

    When looking at phpmyadmin these are the system variables i have related to charsets etc:

    character set client utf8
    (Global value) latin1
    character set connection utf8
    (Global value) latin1
    character set database latin1
    character set filesystem binary
    character set results utf8
    (Global value) latin1
    character set server latin1
    character set system utf8
    character sets dir /usr/share/mysql/charsets/
    collation connection utf8_unicode_ci
    (Global value) latin1_swedish_ci
    collation database latin1_swedish_ci
    collation server latin1_swedish_ci

    When viewing via a command terminal (I think this is ansi?) it displays as Arabic text fine.

    Does anybody know what could be the problem? Could it have to do with some of the global values above not being set to utf-8? If so, does anyone know how to change these? I can't seem to find where to change them.

    Also, with respects to one of the above list items which defines the character sets dir, it says that it's /usr/share/mysql/charsets/, when I look in here I see the following files:

    -rw-r--r-- 1 root root 5528 2006-09-05 10:56 armscii8.xml
    -rw-r--r-- 1 root root 5514 2006-09-05 10:56 ascii.xml
    -rw-r--r-- 1 root root 7412 2006-09-05 10:56 cp1250.xml
    -rw-r--r-- 1 root root 8364 2006-09-05 10:56 cp1251.xml
    -rw-r--r-- 1 root root 5577 2006-09-05 10:56 cp1256.xml
    -rw-r--r-- 1 root root 8910 2006-09-05 10:56 cp1257.xml
    -rw-r--r-- 1 root root 5514 2006-09-05 10:56 cp850.xml
    -rw-r--r-- 1 root root 5530 2006-09-05 10:56 cp852.xml
    -rw-r--r-- 1 root root 5621 2006-09-05 10:56 cp866.xml
    -rw-r--r-- 1 root root 6537 2006-09-05 10:56 dec8.xml
    -rw-r--r-- 1 root root 5524 2006-09-05 10:56 geostd8.xml
    -rw-r--r-- 1 root root 5736 2006-09-05 10:56 greek.xml
    -rw-r--r-- 1 root root 5519 2006-09-05 10:56 hebrew.xml
    -rw-r--r-- 1 root root 5510 2006-09-05 10:56 hp8.xml
    -rw-r--r-- 1 root root 18221 2006-09-05 10:56 Index.xml
    -rw-r--r-- 1 root root 5537 2006-09-05 10:56 keybcs2.xml
    -rw-r--r-- 1 root root 5518 2006-09-05 10:56 koi8r.xml
    -rw-r--r-- 1 root root 6540 2006-09-05 10:56 koi8u.xml
    -rw-r--r-- 1 root root 9818 2006-09-05 10:56 latin1.xml
    -rw-r--r-- 1 root root 7240 2006-09-05 10:56 latin2.xml
    -rw-r--r-- 1 root root 5517 2006-09-05 10:56 latin5.xml
    -rw-r--r-- 1 root root 7446 2006-09-05 10:56 latin7.xml
    -rw-r--r-- 1 root root 8055 2006-09-05 10:56 macce.xml
    -rw-r--r-- 1 root root 8066 2006-09-05 10:56 macroman.xml
    -rw-r--r-- 1 root root 1758 2006-09-05 10:56 README
    -rw-r--r-- 1 root root 6538 2006-09-05 10:56 swe7.xml

    Should there be utf-8 in there?

    Any help appreciated.

  2. #2
    Join Date
    Aug 2003
    Location
    India
    Posts
    109
    Millo, create a database with utf8 characterset encoding and utf8_general_ci collation.

    Also, add the below query to your script. The right place to execute it would be after your connect() and select_db();

    SET NAMES utf8

    Cheers,
    Celia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •