Created
August 27, 2013 08:41
-
-
Save davispuh/6351158 to your computer and use it in GitHub Desktop.
Test for Ruby ENV encoding bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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