Charsets:UTF-8
From OpenEMM Wiki
This article will describe, how to enable the disabled and therefor hidden UTF-8 support of OpenEMM.
For more information about compatibility, look at this chart.
Contents |
Properly setup the database connection
When the JDBC-driver connects to the MySQL-Server, there is a handshake in which JDBC-driver and MySQL-Server agree upon using a certain charset. Usually, the MySQL-Server tells the JDBC-driver, which charset he would like to use for datatransfer. On recent Linux-Systems, this will be UTF8. But on some systems, the default is still latin1 or even something else. So people may experience, that if they use certain characters in the webinterface, they get stored as a "?" in the database. As you can see in openemm.sql, the database-scheme already uses UTF8 in many places. Even though this is the case, this is not enough. The data between the MySQL-Server and the JDBC-driver must also be exchanged in UTF-8. Therefore you have to do the following:
- open the file /home/openemm/webapps/openemm/htdocs/WEB-INF/classes/emm.properties
- find the jdbc.url-setting within that file
- add "?characterEncoding=utf8" to the JDBC-url
An example:
before: jdbc.url=jdbc:mysql://localhost/openemm after: jdbc.url=jdbc:mysql://localhost/openemm?characterEncoding=utf8
By doing this, you turn the tide, and the JDBC-driver will tell the MySQL-Server, that it would like to use UTF-8 to exchange data.
From that point on, characters will not be converted to "?" before transmitting them.
NOTE: Note that some tables and columns within the database-scheme are created by using latin1 as the charset. This database-setting will still
cause some effects when using characters beyond latin1. The reason why latin1 is used is unknown to me. Maybe you can safely convert them to use UTF-8 with phpMyAdmin.
NOTE: Instead of configuring OpenEMM, you can also edit the configuration of the MySQL database by opening my.cnf (or my.ini) and add the line "default-character-set = utf8" to mysqld section.
Enable UTF-8 for Mailings, Import, etc.
Our first steps towards UTF-8 Mailings, Imports, etc. are the following:
- open /home/openemm/webapps/openemm/htdocs/WEB-INF/classes/messages.properties
- open /home/openemm/webapps/openemm/htdocs/WEB-INF/classes/messages_de.properties
- open /home/openemm/webapps/openemm/htdocs/WEB-INF/classes/messages_en.properties
- to each of these files, add the following line:
UserRight.Charsets.charset.use.utf_8=UTF-8 (Unicode)
Now we have added translations for the charset.use.utf_8-privilege. The problem is, that no users have this priviledge, so far.
We have to grant this privilege to the admin-user. Then we use the admin-user, to grant the privilege to all other users.
- open the MySQL-database (with phpMyAdmin for example or use the mysql command line interface)
- execute the following SQL:
INSERT INTO admin_group_permission_tbl SET admin_group_id=4, security_token="charset.use.utf_8"
Now the admin-user has the priviledge to use UTF-8. And now the admin-user can give that priviledge to other users.
But unfortunately, OpenEMM seems to use a lot of caches. That's why the changes will not appear immediately. We have to restart OpenEMM, and we have to clear all JSP-Sessions! Therefore we do the following:
- log in as the 'openemm' user:
su su - openemm
- stop OpenEMM:
/home/openemm/bin/OpenEMM.sh stop
- remove all files within htdocs/WEB-INF/sessions
rm -f /home/openemm/webapps/openemm/htdocs/WEB-INF/sessions/*
- start OpenEMM:
/home/openemm/bin/OpenEMM.sh start
Now login into OpenEMM again, and enjoy UTF-8 support.