Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

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
Note:

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.

Note:

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

  1. Change the "HTML Encoding" value in the Store configuration of the Commerce Manager.
  2. 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>
    
  3. 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>
    

Setting the URL encoding

To change the encoding for URLs, modify the URL_ENCODING constant in com.elasticpath.commons.constants.WebConstants.

Warning:

Changing the encoding for URLs is not recommended.