2
<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

2
  • 1
    Can you give us the full error message please?
    – Nerian
    Dec 6, 2011 at 12:54
  • What version of Ruby are you using? Dec 6, 2011 at 13:03

4 Answers 4

2

This seems almost too simple, but why aren't you using &times;?

1
  • why is this answer correct? this is not the utf-8 rails way. lol Dec 7, 2011 at 6:46
2

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".

1

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.

1
#encoding: utf-8
class ClassiClass
end

everything works fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.