Skip to content

Instantly share code, notes, and snippets.

@davispuh davispuh/test.rb
Created Aug 27, 2013

Embed
What would you like to do?
Test for Ruby ENV encoding bug
#!/usr/bin/env ruby
#encoding: utf-8
text = "testing åáâäãā"
test_env = ENV["test"]
test2_env = ENV["åáâäãā"]
puts "="*20
puts text.to_s
puts text.encoding
puts text.inspect
puts "="*20
puts test_env.to_s
puts test_env.to_s.dup.force_encoding("utf-8")
puts test_env.encoding if test_env
puts test_env.inspect
puts "="*20
puts test2_env.to_s
puts test2_env.to_s.dup.force_encoding("utf-8")
puts test2_env.encoding if test2_env
puts test2_env.inspect
puts "="*20
ENV["test2"] = text
test3_env = ENV["test2"]
puts test3_env.to_s
puts test3_env.to_s.dup.force_encoding("utf-8")
puts test3_env.encoding if test3_env
puts test3_env.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.