Page 1 of 1

Wrong character encoding when creating pages

Posted: Fri Sep 26, 2014 12:18 am
by mercury1231
I was trying to add some foreigh language texts to the existing "about us" page in the site demo admin panel. However, upon clicking save button, the content immediately turned into some mess (most likely with wrong character encoding).

Is this a bug or some configuration that I can tune up?


QQ图片20140925221724.jpg
QQ图片20140925221724.jpg (99.42 KiB) Viewed 9722 times

Re: Wrong character encoding when creating pages

Posted: Fri Sep 26, 2014 11:52 am
by phillipuniverse
What version of Broadleaf are you using? And can you verify that everything in your database is set to UTF-8 encoding? For example, the default for MySQL is Latin1.

Re: Wrong character encoding when creating pages

Posted: Tue Sep 30, 2014 1:08 am
by mercury1231
I'm using UTF8 for my database:

Code: Select all

+-----------+--------------------------------------------------------------------+
| Database  | Create Database                                                    |
+-----------+--------------------------------------------------------------------+
| broadleaf | CREATE DATABASE `broadleaf` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+-----------+--------------------------------------------------------------------+


Code: Select all

mysql> show create table BLC_TRANSLATION;

BLC_TRANSLATION | CREATE TABLE `BLC_TRANSLATION` (
  `TRANSLATION_ID` bigint(20) NOT NULL,
  `ENTITY_ID` varchar(255) DEFAULT NULL,
  `ENTITY_TYPE` varchar(255) DEFAULT NULL,
  `FIELD_NAME` varchar(255) DEFAULT NULL,
  `LOCALE_CODE` varchar(255) DEFAULT NULL,
  `TRANSLATED_VALUE` longtext,
  PRIMARY KEY (`TRANSLATION_ID`),
  KEY `TRANSLATION_INDEX` (`ENTITY_TYPE`,`ENTITY_ID`,`FIELD_NAME`,`LOCALE_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |


my broadleaf version is 3.1.7-GA. Tomcat version is 8.

Re: Wrong character encoding when creating pages

Posted: Tue Sep 30, 2014 1:09 am
by mercury1231
BTW this happening to my category name translations as well (just in a slightly different way).

Re: Wrong character encoding when creating pages

Posted: Tue Sep 30, 2014 3:26 pm
by phillipuniverse
Ensure that your connection string has UTF-8 properties on it like jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&characterEncoding=utf8.

Re: Wrong character encoding when creating pages

Posted: Tue Sep 30, 2014 4:05 pm
by mercury1231
I seem to have added characterEncoding=UTF-8 in all my connection URLs in src/main/webapp/META-INF/context.xml

Code: Select all

url="jdbc:mysql://localhost:3306/broadleaf?autoReconnect=true&useEncoding=true&characterEncoding=UTF-8"