Reputation: 5005
<a class="close" href="#">×</a>
I get an error regarding the use of ×
.
It's used in error messages on twitter's bootstrap framework, I get an invalid byte sequence in UTF-8
error when I try to use it. Is there any work-around? Apart from using a normal x or X.
I have:
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
In my application.rb
Upvotes: 2
Views: 681
Reputation: 2280
#encoding: utf-8
class ClassiClass
end
everything works fine!
Upvotes: 1
Reputation: 395
What editor are you using?
I suspect that you are saving the source file using an encoding other than UTF-8 (such as Latin-1 or ANSI on Windows), which is then causing ruby to fail to interpret the file correctly.
I've tried adding the times symbol to one of my views (using HAML) and it worked correctly. I'm using VIM as my editor and saving in UTF-8 without any BOM.
Upvotes: 1
Reputation: 51707
You need to set the encoding at the top of the file where that character is used. You can do this with:
# coding: utf-8
class MyClass
end
I haven't tried it in an erb file, but I don't see why that would be any different. I think you can use the word "encoding" too instead of just "coding" if that feels better. All that is required is at minimum "coding".
Upvotes: 2