Project

General

Profile

Bug #7267 » test.rb

Test script - kennygrant (Kenny Grant), 11/02/2012 07:54 PM

 
#!/Users/kenny/.rvm/rubies/ruby-2.0.0-preview1/bin/ruby
#!encoding:UTF-8
def inspect_string s
puts "Source encoding: #{"".encoding}"
puts "External encoding: #{Encoding.default_external}"
puts "Name: #{s.inspect}"
puts "Encoding: #{s.encoding}"
puts "Chars: #{s.chars.to_a.inspect}"
puts "Codepoints: #{s.codepoints.to_a.inspect}"
puts "Bytes: #{s.bytes.to_a.inspect}"
end

def transform_string s
puts "Testing string #{s}"
puts s.gsub(/é/u,'TEST')
end



Dir.glob("./*.txt").each do |f|

puts `ruby -v`

puts "Inline string works as expected"
s = "./Testé.txt"
inspect_string s
puts transform_string s

puts "File name from Dir.glob does not"
inspect_string f
puts transform_string f
puts "Encoded file name works as expected, though it is reported as UTF-8"
f.encode!('UTF-8','UTF-8-MAC')
inspect_string s
puts transform_string f
end
(1-1/4)