Arabic Characters Not Displaying

Arabic Characters Not Displaying

by Zach Evans -
Number of replies: 9

We're trying to copy-and-paste an already-translated course that is in Arabic (Farsi) characters into the WYSIWYG editor to create an Arabic-language course. However, when you save the page, all of the Arabic characters are changed to question marks (?). We already have the Farsi language pack installed but this doesn't seem to be helping. Any ideas?

I'm sure we'll have the same problem with Chinese and Japanese characters so I'm looking for a universal fix. Thanks!

Average of ratings: -
In reply to Zach Evans

Re: Arabic Characters Not Displaying

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Which version of Moodle?
In reply to Tim Hunt

Re: Arabic Characters Not Displaying

by Zach Evans -

We're running Moodle v1.7.1.

You can see a sample of what I'm talking about at:

http://www.nationsu.net/course/view.php?id=11

Thanks!

In reply to Zach Evans

Re: Arabic Characters Not Displaying

by Dick Taytor -
Hi Zach,

Hope you figured it out by now...

Anyway, I would hazard a guess that your database is not set to utf8. I faced the same problem with Chinese. Apparently the database is set to latin1-swedish by default. It needs to be in Unicode to handle all the interesting stuff...wink

Brian
In reply to Dick Taytor

Re: Arabic Characters Not Displaying

by Dr. Ali Abureesh -
Picture of Core developers Picture of Translators
You're right Brain it the a database problem. CHARACTER SET of all tables must be set to utf8_general_ci instead of latin1_swedish_ci.
This could be done via Phpmyadmin.
In reply to Dr. Ali Abureesh

Re: Arabic Characters Not Displaying

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
I just came across this problem on a Japanese site (Moodle 1.7 set up with Fantastico).

A temporary workaround is :
  1. open "lib/dmlib.php" with a text editor
  2. locate the following lines
    if ($CFG->unicodedb) {
    $db->Execute("SET NAMES 'utf8'");
    }
  3. replace the above lines with
    if ($CFG->unicodedb) {
    // $db->Execute("SET NAMES 'utf8'");
    }
  4. save the modified file
However, the better workaround is to convert the database to unicode. I think this is more complicated that just setting the CHARSET or COLLOCATION using phpMyAdmin, because you need to convert all the data that has already been input into the database using the "latin1_swedish" encoding.

To make sure the data in the database is correctly converted to unicode, you should run the Moodle unicode migration script:
  1. backup your Moodle database (e.g. create a new DB using cPanel and use phpMyAdmin to copy the current DB to the new one)
  2. open your "config.php" file and remove the following line if you see it:
    $CFG->unicodedb = 1;
  3. using phpMyAdmin, locate the "config" table. If it contains a "unicodedb" record, set the value to "0"
  4. login to Moodle and set Site -> Debugging to the maximum level, i.e. DEVELOPER
  5. access the following URL on your site:
    admin/utfdbmigrate.php
  6. run the migration script, wait patiently while it runs, and verify it completes successfully
If all goes well, the database is now converted to unicode and you can copy and paste characters from ANY language into Moodle.

good luck!
Gordon
Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: Arabic Characters Not Displaying

by Krystie A -

Hi Gordon,

I am trying to get Japanese script working on my site - Moodle 1.8.2 on Fantastico Deluxe.

I followed all of your instrictions, up until stage 5. I can't work out how to...

"access the following URL on your site: admin/utfdbmigrate.php"

I cannot find this file anywhere. Can you please tell me how to get it running, please? Or perhaps, is it different for my version?

In reply to Krystie A

Re: Arabic Characters Not Displaying

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
A moodle 1.8 doesn't have the migration possibilities anymore - this could only be done with a 1.6 and a 1.7.

If you have newly installed 1.8, then it is always utf8. You can't upgrade to 1.8 before migrating your database to utf8 if you come from a previous version. Please tell us your history to be able to help you.
In reply to Zach Evans

Re: Arabic Characters Not Displaying

by Filip Giesz -
If your database/PHP versions are beyond your control, you can prevent this whole problem by saving your Farsi to PDF and make sure you embed only the used characters in the font. Then, post the PDF in the files area OR put them in your home page (hidden directory works fine) and provide hard links to them in Moodle. My wife has been doing that for years with BB for Chinese. Bonus: *always* works for the student and prints nicely too.