Openfire: Offline UTF-8 encoded messages are saved wrong

我只是一个虾纸丫 提交于 2019-12-01 07:12:19

问题



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 ????.


回答1:


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.



来源:https://stackoverflow.com/questions/25358854/openfire-offline-utf-8-encoded-messages-are-saved-wrong

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!