“Foreign language” characters

March 2nd, 2006 by papillon

The application I am working on is in german, so Rails needs to display Umlauts correctly (e.g. ä,ö,ü). At least with WebBrick, I was not able to convince it to send pages in ISO-8859-1, it always defaulted to UTF-8 which the Browsers would not interprete correctly.

My temporary solution is to overwrite the default codepage like this:

class ApplicationController < ActionController::Base
  before_filter :set_charset
  def set_charset
    @headers["Content-Type"] = "text/html; charset=ISO-8859-1"
  end
end

Using that, the Umlauts appear correctly in all Browsers. Oh well, it works for now…