Project

General

Profile

Actions

Bug #178

closed

File.open on sprintf-formatted string fails with encoding conversion error on OS X

Added by drbrain (Eric Hodel) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
Backport:
[ruby-core:17310]

Description

=begin
String#% and File.open are interacting strangely on OS X, so files opened with a sprintf formatted string raise an ArgumentError:

$ ruby19 -vwe 'File.new("foo" % [])'
ruby 1.9.0 (2008-06-18 revision 15873) [i686-darwin9.3.0]
-e:1:in initialize': transcoding not supported (from US-ASCII to UTF8-MAC) (ArgumentError) from -e:1:in new'
from -e:1:in `'

Using just "foo" as the filename works fine:

$ ruby19 -we 'File.new("foo")'

As does String#<<:

$ ruby19 -we 'File.new("foo" << "")'
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0