0

How do I change my default charset from ANSI to Unicode in my project? When I write special characters as Æ Ø Å in my view that is ANSI it renders a error. But if I change the file to UTF-8 encoding it renders the special characters without a error. Should I then change all my view files from ANSI encoding to UTF-8 ?

3
  • Can you describe your problem? I didn't have to change a thing to use unicode. Commented Feb 26, 2011 at 0:52
  • Yes, you should change all view files from ANSI to UTF-8, cause using ANSI is an old standard. Commented Feb 26, 2011 at 1:21
  • Can I set utf 8 as default in rails when creating a new project Commented Feb 26, 2011 at 1:23

1 Answer 1

1

Here is some rails magic - add this comment to your .rb file:

# coding: utf-8 

and it should work)

You also can use Iconv class to convert your string to UTF-8 like this:

require 'iconv' ic = Iconv.new('WINDOWS-1251','UTF-8') new_string = ic.iconv(old_string) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.