Project

General

Profile

Backport #2762

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

=begin 
  
  Current stalbe ruby 1.9.1 has problems with UTF/Unicode strings coming from backticks. 
  Reading the file with File.read('filename') works as expected. Only using backticks gives an error in a substitution afterwards: 
  in `sub!': invalid byte sequence in UTF-8 (ArgumentError) 
 
  This is my test skript: 
  #!/usr/bin/env ruby 
  puts "Using ruby #{RUBY_VERSION} on #{RUBY_PLATFORM} from #{RUBY_RELEASE_DATE}" 
  puts "File.read:" 
  File.read('testString.txt').sub!(/foo.*/, "hallo") 
  puts "    success" 
  puts "backticks:" 
  `cat testString.txt`.sub!(/foo.*/, "hallo") 
  puts "    success" 
  puts "No problem in this version" 
 
 
  And this is the output on the ruby versions I tested: 
 
  Using ruby 1.8.7 on x86_64-linux from 2010-01-10 
  File.read: 
    success 
  backticks: 
    success 
  No problem in this version 
 
  Using ruby 1.9.1 on x86_64-linux from 2010-01-10 
  File.read: 
    success 
  backticks: 
  ./test.rb:9:in `sub!': invalid byte sequence in UTF-8 (ArgumentError) 
          from ./test.rb:9:in `<main> 
 
  Using ruby 1.9.2 on x86_64-linux from 2010-02-13 
  File.read: 
    success 
  backticks: 
    success 
  No problem in this version 
 
  (using revision 26652 for 1.9.2) 
 
 
  So it is working in 1.9.2 again, but could this fix get backported to stable 1.9.1? I could not find out which revision this is fixed though, because I had trouble compiling older revisions. 
 
 =end 
 

Back