Defect #41434 » 41434-csv-crlf.patch
app/models/import.rb | ||
---|---|---|
72 | 72 |
content = read_file_head |
73 | 73 | |
74 | 74 |
separator = [',', ';'].max_by {|sep| content.count(sep)} |
75 |
newline = content.index("\r\n") ? "\r\n" : '' # blank means auto |
|
75 | 76 |
wrapper = ['"', "'"].max_by {|quote_char| content.count(quote_char)} |
76 | 77 | |
77 | 78 |
guessed_encoding = Redmine::CodesetUtil.guess_encoding(content) |
... | ... | |
89 | 90 | |
90 | 91 |
self.settings.merge!( |
91 | 92 |
'separator' => separator, |
93 |
'newline' => newline, |
|
92 | 94 |
'wrapper' => wrapper, |
93 | 95 |
'encoding' => encoding, |
94 | 96 |
'date_format' => date_format, |
... | ... | |
270 | 272 |
csv_options[:encoding] = 'bom|UTF-8' if csv_options[:encoding] == 'UTF-8' |
271 | 273 |
separator = settings['separator'].to_s |
272 | 274 |
csv_options[:col_sep] = separator if separator.size == 1 |
275 |
newline = setting['newline'].to_s |
|
276 |
csv_options[:row_sep] = newline if newline.present? |
|
273 | 277 |
wrapper = settings['wrapper'].to_s |
274 | 278 |
csv_options[:quote_char] = wrapper if wrapper.size == 1 |
275 | 279 |
- « Previous
- 1
- 2
- 3
- 4
- Next »