2

My previous question is answered but there's a few more things I don't understand.

I have a yaml file which contains a field with a utf-8 character:

:name: O\xE2\x80\x99Reilly 

When I load the yaml in irb:

>puts name.encoding => UTF-8
>name => "O\xE2\x80\x99Reilly"
>puts name => O’Reilly

When I load the yaml in Rails:

>puts name.encoding => UTF-8 
>puts name => Oâ[80][99]Reilly
>puts name.force_encoding('utf-8') => Oâ[80][99]Reilly
>puts Iconv('iso-8859-1', '', name) => O’Reilly

Q3: Why does rails print it's initial utf-8 string as if it's iso-8859-1, and the string converted to iso-8859-1 as if it's utf-8?

Community
  • 1
  • 1
Cookies
  • 135
  • 8

1 Answers1

1

Your config/application.rb file in rails probably has this:

config.encoding = "utf-8"

This is only an answer to the first Q and may or may not have any relevance to the next 2 :)

Adnan
  • 2,949
  • 4
  • 29
  • 45