Troubleshooting Character Encoding Issues

By Cory LaViska on April 17, 2019

If you publish changes and see strange characters appear aftwards, chances are the page's character encoding is wrong. This post will show you how to fix that.

Letters scattered on a table

Surreal CMS publishes content using the UTF-8 character encoding. UTF-8 is capable of representing every character in the Unicode character set, including those from many different alphabets. If you publish a page and notice strange characters appearing, chances are your pages are not being served as UTF-8.

The solution is to tell browsers to use UTF-8 encoding. There are a few ways to do this, but the easiest is with a special meta tag. To tell browsers to use UTF-8 on your pages, Surreal CMS will add the following meta tag in your pages.

<meta charset="utf-8">

The idea is to solve the problem before it becomes one, but sometimes that's not enough.


If adding the meta tag doesn't solve the problem, your server is probably sending a conflicting header. Depending on your server, there are a few things you can try.

.htaccess

If your server supports .htaccess, add the following line.

AddDefaultCharset UTF-8
ASP

If you're using ASP, add this to web.config.

<globalization
  requestEncoding="utf-8"
  responseEncoding="utf-8"
  fileEncoding="utf-8"
/>
ColdFusion

If you're using ColdFusion, add this to the affected page.

<cfprocessingdirective pageencoding="utf-8">

Still seeing strange characters? Let us know and we'll be happy to take a look!