h3raLd
10/23/2007 12:45:00 PM
Hello,
I noticed some weird behavior when converting a string containing
international characters to YAML:
irb(main):002:0> 'test òùè'.to_yaml
=> "--- \"test \\x95\\x97\\x8A\"\n"
irb(main):003:0>
....but:
irb(main):001:0> 'test òùè'
=> "test \225\227\212"
Basically, the to_yaml method seems to use some strange hex escape
sequences which do not correspond to ANSI, UTF-8 or windows-1252...
The funny part is that when I load the same string from YAML, it is
displayed correctly in the console. This would be fine, except that
when I tried to save it to a file the international characters are not
displayed properly (or better, they are converted to the corresponding
ANSI/UTF-8 characters). What's going on here? What encoding does
to_yaml use to escape international characters?
According to the docs it should be UTF-8, but apparently it is not.
Ruby version: 1.8.6
OS: Windows XP
Any ideas?