File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -1506,17 +1506,7 @@ def generate_line(row, **options)
1506
1506
if options [ :encoding ]
1507
1507
str . force_encoding ( options [ :encoding ] )
1508
1508
else
1509
- fallback_encoding = nil
1510
- output_encoding = nil
1511
- row . each do |field |
1512
- next unless field . is_a? ( String )
1513
- fallback_encoding ||= field . encoding
1514
- next if field . ascii_only?
1515
- output_encoding = field . encoding
1516
- break
1517
- end
1518
- output_encoding ||= fallback_encoding
1519
- if output_encoding
1509
+ if output_encoding = row_encoding ( row )
1520
1510
str . force_encoding ( output_encoding )
1521
1511
end
1522
1512
end
@@ -1960,6 +1950,20 @@ def table(path, **options)
1960
1950
private_constant :ON_WINDOWS
1961
1951
1962
1952
private
1953
+
1954
+ def row_encoding ( row )
1955
+ fallback_encoding = nil
1956
+ output_encoding = nil
1957
+ row . each do |field |
1958
+ next unless field . is_a? ( String )
1959
+ fallback_encoding ||= field . encoding
1960
+ next if field . ascii_only?
1961
+ output_encoding = field . encoding
1962
+ break
1963
+ end
1964
+ output_encoding || fallback_encoding
1965
+ end
1966
+
1963
1967
def may_enable_bom_detection_automatically ( filename_or_io ,
1964
1968
mode ,
1965
1969
options ,
You can’t perform that action at this time.
0 commit comments