mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* 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:
parent
47a1cd1291
commit
d05217109f
13 changed files with 80 additions and 54 deletions
14
lib/csv.rb
14
lib/csv.rb
|
@ -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
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue