Project

General

Profile

Actions

Backport #2762

closed

in `sub!': invalid byte sequence in UTF-8 (ArgumentError); using backticks

Added by JonnyJD (Johannes Dewender) about 14 years ago. Updated over 4 years ago.

Status:
Closed
[ruby-core:28246]

Description

=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

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


Files

testString.txt (43 KB) testString.txt test file giving an error with test.rb on 1.9.1 JonnyJD (Johannes Dewender), 02/19/2010 07:13 AM
test.rb (302 Bytes) test.rb test script JonnyJD (Johannes Dewender), 02/19/2010 07:13 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0