From 3077ed8d3a79fc613f31ecd47418fcec291cfd18 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 13 Jun 2015 07:55:30 +0000 Subject: Add BOM to UTF-8 encoded CSV (#7037). git-svn-id: http://svn.redmine.org/redmine/trunk@14303 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/export/csv.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/redmine/export/csv.rb b/lib/redmine/export/csv.rb index ce43240ba..3762eb661 100644 --- a/lib/redmine/export/csv.rb +++ b/lib/redmine/export/csv.rb @@ -35,7 +35,13 @@ module Redmine col_sep = l(:general_csv_separator) encoding = l(:general_csv_encoding) - super(:col_sep => col_sep, :encoding => encoding, &block) + str = ''.force_encoding(encoding) + if encoding == 'UTF-8' + # BOM + str = "\xEF\xBB\xBF".force_encoding(encoding) + end + + super(str, :col_sep => col_sep, :encoding => encoding, &block) end end -- cgit v1.2.3