Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

This page is outdated and no longer receives updates!

Requirements for Using UTF-8

...

Code Block
CREATE DATABASE openmrs
 
DEFAULT CHARACTER SET utf8
 
DEFAULT COLLATE utf8_general_ci;

Add the following lines to the MySQL configuration file"[mysqld]" and "[mysql]" sections of the MySQL configuration file, adding the sections if necessary. For Ubuntu, the file is located in /etc/mysql/my.cnf.

Code Block
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci


[mysql]
default-character-set=utf8

For interested developers

...

The java Properties class has two methods (load() and store()) that don't support UTF-8, that were used in a couple of places, most notably when loading message string files. There are now alternate methods that you can use in OpenmrsUtil that preform the same function, but read and write using UTF-8.

Reading in UTF-8 files

There is an interested Java issue involving reading in a UTF-8 file.  Some applications (including Microsoft Notepad) add a special character called a byte order mark to the beginning of a UTF-8 file, but Java's standard encoding doesn't support this:

http://bugs.sun.com/view_bug.do?bug_id=4508058

A workaround that *appears* to fix the issue (I haven't done serious testing) is to wrap a file input stream in an org.apache.velocity.io.UnicodeInputStream instance, which is specifically designed to be BOM-aware.  (There is also a BOMInputStream in apache.commons.io, but in a later version of the jar than is included in Openmrs 1.6).