1

in my template (index.html.erb) is no line for any code like utf-8 or anything. so rails of course has a problem with that.

    Your template was not saved as valid UTF-8. Please either specify UTF-8 as the encoding for your template in your text editor, or mark the template with its encoding by inserting the following as the first line of the template:

# encoding: <name of correct encoding>.

so i tried to paste this into my html: # encoding: < meta charset=utf-8 />.

did i write something wrong? or can i take any other code?

The answer from rails is: unknown encoding name - <

thanks for answering

5 Answers 5

4

check if the file itself is saved as UTF-8.

This was my problem.

Using "e" as a texteditor or Notepad++ (or any other (windows) tool ) with wrong configuration may be the problem.

e (and i think Notepad++) was configured to save the files as "Windows DOS OEM (EP 437)".

I've changed this in the settings to UTF-8, saved alle files (withoth changes) and it works.

Sign up to request clarification or add additional context in comments.

1 Comment

This was the problem for me, too. I'm using Eclipse, which I just discovered to Cp1252. I changed it to UTF-8 and saved the file again and the problem disappeared.
4

in your application.rb file paste this line

config.encoding = "utf-8"

or in your application.html.erb file paste the following line

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Comments

1

The meta charset is for HTML. You need to specify the charset for ruby, you can do it by using a comment like this:

# encoding: utf-8

2 Comments

yeah, sounds logical, thanks. But I can put the comment wherever I want (at the the top of the document like it's written or in the head), it still gives me the same error. Can't explain why...
Are you sure that you saved the template file in UTF8 encoding? What exactly did you write in the template file?
0

Using Rubymine4, accidentally right clicked and didn't see what I had pressed... BANG! code = gone! Plus 1 error! I had reencoded the page to some crazy encoding. Just right click in page and -> save '[Your crazy Encoding here]' file in another encoding.

Rubymine, too easy! ;)

Comments

0

That solved for me. It was my file that was not being saved as utf-8 after all.

https://superuser.com/questions/581553/sublime-text-2-encoding-utf-8

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.