* lib/csv.rb, test/csv: should not assume $, invariant.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-12-25 06:58:58 +00:00
parent 47a1cd1291
commit d05217109f
13 changed files with 80 additions and 54 deletions

View file

@ -505,12 +505,12 @@ class CSV
end
str << ">"
begin
str.join
str.join('')
rescue # any encoding error
str.map do |s|
e = Encoding::Converter.asciicompat_encoding(s.encoding)
e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
end.join
end.join('')
end
end
end
@ -845,7 +845,7 @@ class CSV
else
rows + [row.fields.to_csv(options)]
end
end.join
end.join('')
end
alias_method :to_s, :to_csv
@ -1973,12 +1973,12 @@ class CSV
end
str << ">"
begin
str.join
str.join('')
rescue # any encoding error
str.map do |s|
e = Encoding::Converter.asciicompat_encoding(s.encoding)
e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
end.join
end.join('')
end
end
@ -2262,7 +2262,7 @@ class CSV
# a backslash cannot be transcoded.
#
def escape_re(str)
str.chars.map { |c| @re_chars.include?(c) ? @re_esc + c : c }.join
str.chars.map { |c| @re_chars.include?(c) ? @re_esc + c : c }.join('')
end
#
@ -2278,7 +2278,7 @@ class CSV
# that encoding.
#
def encode_str(*chunks)
chunks.map { |chunk| chunk.encode(@encoding.name) }.join
chunks.map { |chunk| chunk.encode(@encoding.name) }.join('')
end
#