/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Making a Sinatra app respect UTF-8: # # 1. At the top of your app file, set $KCODE to 'u'. # This ensures your regexps are in UTF-8 mode by default, # and #inspect will output UTF-8 chracters correctly. # This option is on by default as of Ruby 1.9. # For more information on the $KCODE setting, see: # http://blog.grayproductions.net/articles/the_kcode_variable_and_jcode_library $KCODE = 'u' if RUBY_VERSION < '1.9' # 2. Set content-type with charset=utf-8 param (not the default setting.) # This ensures the browser will render utf-8 characters correctly. # A before filter is a good place to do this: before do content_type :html, 'charset' => 'utf-8' end
Comments
