Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

UTF-8 contrib

From MoodleDocs

UTF-8 migration > Contrib

How to make your contrib module work for the UTF-8 migration process

The UTF-8 migration script traverse Moodle modules same way as the module upgrade process.

For the purpose of making Moodle totally UTF-8, every field of type (varchar, text, enum) will need to be converted to UTF-8.

To do this, you need to put 2 files in the db folder, where the mysql.sql and postgres.sql files are.

  • migrate2utf8.xml defines what fields to be converted. Every field needs a type and a length, and if applicable, index information (see below). There are 3 methods associated with each field:
  1. -NO_CONV is for those fields that could only contain English Chars, written by Moodle.
  2. -PLAIN_SQL_UPDATE is used when you can find both the user language and course language for that record using 1 SQL conveniently. If you use this method you muse include both sqls for the user lang and the course lang.
  3. -PHP_FUNCTION is used when the detection of userlang or courselang is more difficult, or more sophisticated methods are needed for the conversion (e.g. serialized objects, or when you need to append _utf8 to a lang field etc)
  • migrate2utf8.php defines each php function included to do the conversion.

Please look at forum/db for the exact formats of these files.

All indexes need to be dropped prior to (or at the same time) the processing this field. This can be done using dropindex or dropprimary. After the field is processed, you need to add the indexes back using addindex, adduniqueindex, or addprimary. If you don't have enough fields in the table to do addindex or dropindex, you can add arbitrary number of dummy fields (see scorm/db/migrate2utf8.xlm)

To test the migration, please don't forget to turn debug on.

Manually converting a table to UTF-8

If you have extra tables that contain text in English or UTF encoding from Moodle 1.5, and you want to convert them manually to be used under 1.6, here is a procedure: