#reminder
Ruby was written in Japanese and does not stick with a specific encoding standard. That can bring you some distresses if you need latin or other special characters running on your app.
If you are running Ruby version 1.9 (or up) don’t forget about this “if & thens” :
1. if:
puts "café" on any Ruby script
brings you
invalid multibyte char (US-ASCII) (SyntaxError)
then:
use the following magic comment (as it was named)
# encoding: UTF-8
on the first line of your script
if on you .erb template:
<%= "å".encoding%>
outputs ASCII-8BIT and
<%= "å".force_encoding('utf-8') %>
outputs å and you need to be passing this ASCII-8BIT typed strings around…
then:
you’ll need to convert this strings to UTF-8
p string.encoding.name
outputs ASCII-8BIT
string.force_encoding("UTF-8")
pstring.encoding.name
outputs UTF-8
PS: Careful on partials. They also break all the stuff if not encoded.
<%= partial("admin/menu").force_encoding("UTF-8") %>