Project

General

Profile

Patch #28112 ยป redmine_with_ruby250.patch

Sho HASHIMOTO, 2018-01-31 12:08

View differences:

lib/redmine/export/csv.rb
29 29
      class Base < ::CSV
30 30
        include Redmine::I18n
31 31

  
32
        BOM = "\xEF\xBB\xBF".force_encoding('UTF-8')
32 33
        class << self
33 34

  
34 35
          def generate(&block)
35 36
            col_sep = l(:general_csv_separator)
36 37
            encoding = l(:general_csv_encoding)
37 38

  
38
            str = ''.force_encoding(encoding)
39
            if encoding == 'UTF-8'
40
              # BOM
41
              str = "\xEF\xBB\xBF".force_encoding(encoding)
39
            res = super(:col_sep => col_sep, :encoding => encoding, &block)
40
            if encoding == 'UTF-8' && !res.starts_with?(BOM)
41
              res = BOM + res
42 42
            end
43

  
44
            super(str, :col_sep => col_sep, :encoding => encoding, &block)
43
            return res
45 44
          end
46 45
        end
47 46

  
    (1-1/1)