utf-8

by David Weldon

I recently had a problem where I was rendering an ErlyDTL template and symbols like © and ® were not displaying right. After a little trial and error I realised that the character encoding in my HTML template was set to UTF-8, but erlang’s default encoding is ISO-latin-1 (ISO8859-1). Fortunately the unicode  module provides an easy fix for this:

{ok, Html} = my_template_dtl:render(Data),
unicode:characters_to_binary(Html).

And voilà, we have a UTF-8 binary.

Advertisements