2010/1/14 Marcelo Cavaco <marcelocavaco / veloxmail.com.br>:
> hi everybody,
>
> please help...
>
> i have a file (Documentao.txt) with this structure:
>
> my_data << [0, "Ao", Zlib::Deflate.deflate("Sample Text!!!")].to_a
> my_data << [0, "Test", Zlib::Deflate.deflate("Only ASCII
> chars!!!")].to_a
> my_data << [0, "Test char ", Zlib::Deflate.deflate("New test
> ()")].to_a
>
> OBS: i not create this file!!!
>
> and i have this code:
>
> require 'fileutils'
> require 'zlib'
> DestFile = "D:\\temp\\app\\Documentao.txt"
> my_read_data = File.open(DestFile, 'rb') { |f| Marshal.load f }
> my_read_data.each do |item|
> file_path = "D:\\temp\\app\\new_files_" + item[1] + ".txt"
> file_text = Zlib::Inflate.inflate(item[2])
> File.open(file_path, 'wb') { |file| file.write(file_text) }

I'd say you probably rather should open this file in text mode since
you are looking at it in text mode - maybe with a particular encoding
(see link below).

> end
>
> the result is
>
> new_files_Ao.txt
> new_files_Test.txt
> new_files_Test char ик.txt
>
> and not
>
> new_files_Ao.txt
> new_files_Test.txt
> new_files_Test char .txt
>
> why this occurs?
>
> is the encode???

Likely.

> how change ?

James has an excellent blog posting about this:
http://blog.grayproductions.net/articles/miscellaneous_m17n_details

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/