Character set encoding
Character set encoding
The default encoding in Elastic Path is UTF-8. This applies to:
- Database data
- Database communications
- Content (HTML pages, emails)
- Data files (import data files, report files)
- URLs (catalog browsing URLs, search URLs)
Setting the database encoding
You will need to specify the encoding when you create a database and set your database server to use the same encoding. For example, to use the UTF-8 encoding for a MySQL database, create the database as follows:
create database DB_NAME character set utf8;
Make sure the MySQL Server encoding is set to UTF-8:
- In the Server my.ini file (.../MySQL/MySQL Server 5.1/my.ini), set the default-character-set to utf8:
[mysqld] ... default-character-set=utf8
The corresponding JDBC URI is:
jdbc:mysql://localhost:3306/COMMERCE_DB?autoReconnect=true
Specifying the encoding type in the JDBC URL ("jdbc:mysql://localhost:3306/COMMERCE_DB?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"), won't be enough to set database communications to use UTF-8. Character encoding is overridden by the MySQL Server's character setting.
You may encounter problems when using some Asian encodings that use a double wide character set, which makes some fields require twice as much storage space. In this case, the schema may need to be updated to accommodate the longer strings.
Setting content encoding
- Change the "HTML Encoding" value in the Store configuration of the Commerce Manager client.
- Change the following settings in velocity.xml
<prop key="template.encoding">UTF-8</prop> <prop key="input.encoding">UTF-8</prop> <prop key="output.encoding">UTF-8</prop>
- Change the following settings in web.xml:
<!-- Encoding filter --> <filter> <filter-name>Encoding Filter</filter-name> <filter-class>com.elasticpath.commons.filter.impl.EncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter>