# Ruby 1.9, YAML & encodings

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-yaml-encodings/145735>\
**Category:** Ruby\
**Created:** [August 13, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/ruby-1-9-yaml-encodings/145735 "2008-08-13T13:45:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FSSenault](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/73ab20/32.png) [@FSSenault](https://www.ruby-forum.com/u/FSSenault)\
**Post date:** [August 13, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/ruby-1-9-yaml-encodings/145735/1 "2008-08-13T13:45:34Z")

</div>

Hello all.

I’m trying to migrate a project to ruby 1.9.

I have a lot of source, ressource, and data files, all encoded in  
ISO8859-1(5), so I’m trying to preserve this.

The trouble is that YAML seems to load every string file that contains a  
non ASCII char with an encoding of “ASCII-8BIT” ; if I understand  
correctly, it should follow the Encoding.default\_external value.

A small example session :

13:20 fred@balvenie:~/ruby/blackops\> ruby19 -v  
ruby 1.9.0 (2008-07-25 revision 18217) [i386-freebsd6]  
13:20 fred@balvenie:~/ruby/blackops\> irb19

> > require “yaml”  
> > =\> true
> 
> > Encoding.default\_external  
> > =\> #Encoding:ISO-8859-15
> 
> > txt = “\351\351\351”  
> > =\> “ééé”
> 
> > txt.encoding  
> > =\> #Encoding:ISO-8859-15
> 
> > z = YAML.load(YAML.dump(txt))  
> > =\> “\351\351\351”
> 
> > z.encoding  
> > =\> #Encoding:ASCII-8BIT
> 
> > z \<\< “\351”  
> > ArgumentError: append incompatible encoding strings: ASCII-8BIT and  
> > ISO-8859-15  
> > from (irb):62  
> > from /usr/local/lib/ruby/1.9/irb.rb:149:in `block (2 levels) in eval_input' from /usr/local/lib/ruby/1.9/irb.rb:262:in`signal\_status’  
> > from /usr/local/lib/ruby/1.9/irb.rb:146:in `block in eval_input' from /usr/local/lib/ruby/1.9/irb.rb:145:in`eval\_input’  
> > from /usr/local/lib/ruby/1.9/irb.rb:69:in `block in start' from /usr/local/lib/ruby/1.9/irb.rb:68:in`catch’  
> > from /usr/local/lib/ruby/1.9/irb.rb:68:in `start' from /usr/local/bin/irb19:12:in`’
> 
> > z.force\_encoding(‘ISO8859-15’)  
> > =\> “ééé”
> 
> > z \<\< “\351”  
> > =\>  
> > “éééé”  
> > Any ideas ?

(Nota : this is a hand compiled 1.9.0-3 version under FreeBSD, but it  
does the same with the official ports version, 1.9.0-1.)  
Fred
