Openfire: Offline UTF-8 encoded messages are saved

2019-02-18 12:34发布


We use Openfire 3.9.3. Its MySql database uses utf8_persian_ci collation and in openfire.xml we have:

...<defaultProvider> 
  <driver>com.mysql.jdbc.Driver</driver>  
  <serverURL>jdbc:mysql://localhost:3306/openfire?useUnicode=true&amp;amp;characterEncoding=UTF-8</serverURL>  
  <mysql> 
    <useUnicode>true</useUnicode> 
  </mysql> ....

The problem is that offline messages which contain Persian characters (UTF-8 encoded) are saved as strings of question marks. For example سلام (means hello in Persian) is stored and showed like ????.

标签: openfire
1条回答
仙女界的扛把子
2楼-- · 2019-02-18 13:12

MySQL does not have proper Unicode support, which makes supporting data in non-Western languages difficult. However, the MySQL JDBC driver has a workaround which can be enabled by adding

?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8

to the URL of the JDBC driver. You can edit the conf/openfire.xml file to add this value.

Note: If the mechanism you use to configure a JDBC URL is XML-based, you will need to use the XML character literal & to separate configuration parameters, as the ampersand is a reserved character for XML.

Also be sure that your DB and tables have utf8 encoding.

查看更多
登录 后发表回答