hi,
i am trying to build and application that accepts different languages
and characters. There is two yaml files: english and frensh. i first
load the content of the French file as a hash array the dump it back
using the following command
File.open(french.yaml, “w”) {|f| YAML.dump(join_hash, f)}
Everything is working fine; however ruby encodes a string with foreign
characters when it converts back to yaml.
e.g
“français”.to_yaml => becomes “fran\xC3\xA7ais”
is there any way i can go around this; i have already wasted two days
researching.
Your help well be greatly appreciated
regards
MO
hi,
i am trying to build and application that accepts different languages
and characters. There is two yaml files: english and frensh. i first
load the content of the French file as a hash array the dump it back
using the following command
File.open(french.yaml, “w”) {|f| YAML.dump(join_hash, f)}
Everything is working fine; however ruby encodes a string with foreign
characters when it converts back to yaml.
e.g
“français”.to_yaml => becomes “fran\xC3\xA7ais”
Well, \xC3\xA7 is the code point for the UTF8 representation of ç, so it
seems to be working at some level.
Ruby does not natively support UTF8. I believe that to enable UTF8
support in Rails you need to add this to your environment.rb file:
Set these for unicode support
$KCODE = ‘u’
require ‘jcode’
However, I cannot say whether or not this will help you in your specific
instance. In ruby script/console running in a DOS box on my Windows XP
your string above renders as “franaceais”