Unicode utf8 display problem, please help

Unicode utf8 display problem, please help

by James Van -
Number of replies: 4

Hello all,

I unsderstand Moodle does not translate user content. "Any user-generated content remains in the language in which it was entered". But the problem I have is that the user-generated-content I created was in unicode, when pasting or typing it on the screen it looks fine. After it's saved, it show up with question mark in the unicode letter . ie: Instead of "Chào" it becomes "Ch?o" on screen. The vi_ unicode in the language pack displays fine. Any suggestion?

I think maybe the mySQL databse is not set for utf8 (but if that's the case, the whole screen should be messed up with lot of ????, not just user-generated-content), where do i check for it ?

I did check and do see character code is set for utf8

Thanks in advance

Average of ratings: -
In reply to James Van

Re: Unicode utf8 display problem, please help

by Petr Gajdoš -
I had the same problem with moodle 1.7 using mysql and apache2. There was definitely problem with mysql setup (see install.php for character-set-* strings), because I got the same problem with ordinary mysql client aplied on mdl_* tables. After two days debugging (mixing various settings of character-set-* variables in mysql database), I tried to upgrade to 1.8, it helped.
In reply to James Van

Re: Unicode utf8 display problem, please help

by Patrick Gosetti-Murrayjohn -
Just wondering if you've figured out the ? issue--I'm having much the same problem.

I'm using Moodle 1.8.2, and the tinyMCE plugin instead of HTML Editor because (1) it's more familiar to my faculty who have used Wordpress and Drupal and (2) I need a plugin that I wrote for tinyMCE to insert vowels with macrons.

Trouble is, the macrons show up great in the tinyMCE editor, but I get ? in the display. Some other unicode characters show up fine, others don't, and I haven't found a pattern to it yet.

The MySQL settings seem to be right according to what I've found digging around the Moodle site, and I haven't had any problems with this in other apps using the same database settings.

One additional piece: when I export the questions that have macrons as XML, the export also has ? where the unicode should be. That makes me think it's not a font issue, but something between the user input and the database.

Any help is much appreciated--we're just doing small exploration to see if a switch to Moodle is right for us, and making this work would be a big step in that direction.

Thanks
In reply to James Van

Re: Unicode utf8 display problem, please help

by Sativa Huang -

Hi James,
Here is the solution. Good luck!

In reply to Sativa Huang

Re: Unicode utf8 display problem, please help

by Sativa Huang -

Hi All,
I installed Moodle 1.8.2 using Fantastico, the database code is Latin1 instead of UTF-8. Thanks to James Chan who show me the solution.

The main issue here is how to change the code to UTF-8. As the scripts provide by James is not applicable for Moodle 1.8 (cmiiw) and it's really tired to do it manually, therefore I have done the following steps to solve this problem:

- Backup the database using MySQL, let's name it mdle1.sql
- Using Notepad or Notepad2 to change latin1 with utf8 (Edit > Replace > Replace All)
- Saving the database (eg. mdle1.sql), Encoding: UTF-8.
- Using PhpMyAdmin to upload and replace the old database.

As a result, the code has been replaced by utf8_general_ci instead of utf8_unicode_ci.

However, our website can display Chinese now (simplified Chinese & traditional Chinese). If you would like to take a look, just click here.

Questions:
1. Is there any problem of applying these steps to change the encoding?
2. Is it alright to use utf8_general_ci?

Thanks!