I’m playing around with Rails and I’m having problems with displaying
swedish characters. This is how far I’ve gotten:
I have a controller…
class MiscController < ApplicationController
@chars_to_display = ‘Ã¥Ã¤Ã¶’
…and a template (swedish_chars.rhtml)Test with swedish chars
These are swedish chars: Ã¥, Ã¤ and Ã¶
Now lets try with a variable: <%= @chars_to_display %>
The thing is that the characters in the first paragraph displays nicely
(the charset of the file swedish_chars.rhtml is set to UTF-8). The
problem is with the second paragraph, the one that displays the content
of the controller set variable @chars_to_display.
There are two types of symptoms depending on which charset I use for the
controller file misc_controller.rb. If I use charset 8-bit the swedish
characters are displayed as ?-characters. If I use charset UTF-8 on the
other hand I get this error from Ruby:
app/controllers/misc_controller.rb:1: Invalid char
\357' in expression app/controllers/misc_controller.rb:1: Invalid char\273’ in expression
app/controllers/misc_controller.rb:1: Invalid char `\277’ in expression
[—Long stack trace removed—]
This error occured while loading the following files:
What am I doing wrong?
Oh yes: I,m using WEBrick as server.