Project

General

Profile

Bug #3533 » EncodingTest.rb

pdwilson12 (Peter Wilson), 07/04/2010 11:01 AM

 
# encoding: utf-8

puts "default_external: #{Encoding.default_external}"
puts "default_internal: #{Encoding.default_internal}"

puts "STDOUT external: #{STDOUT.external_encoding}"
puts "STDOUT internal: #{STDOUT.internal_encoding}"

puts "STDIN external: #{STDIN.external_encoding}"
puts "STDIN internal: #{STDIN.internal_encoding}"

puts

f = File.open("/tmp/test.txt", "w");
puts "File external encoding: #{f.external_encoding}"
line = "olé"
f.puts line.encode("utf-8")
f.puts line.encode("iso-8859-1")
f.close
system "cat /tmp/test.txt"
system "od -t x1 /tmp/test.txt"
    (1-1/1)