Rainer wrote:
> irb(main):001:0> a_string = "Mot?rhead"
> => "Mot\224rhead"
> irb(main):002:0> a_file = File.new("test.txt", "w")
> => #<File:test.txt>
> irb(main):003:0> a_file << a_string
> => #<File:test.txt>
> irb(main):004:0> a_file.close
> => nil
> irb(main):005:0>
> 
> However, when I open "test.txt" with a text editor, I get this result:
> 
> Mot"rhead
> 
> When I read a file with the correct spelling...
> 
> irb(main):006:0> puts File.open("test.txt", "r").readlines
> 
> ..I get this result:
> 
> Mot?rhead
> => nil

This has just been discussed today. You have to use the same charset
encodig for editing your Ruby code, and displaying the program output.
The first is determined (in your above case) by your terminal (because
you entered the code in irb), and the latter by the text editor in question.

If the two encodings don't match, then the byte string will be literally
misinterpreted.

mortee