Feature #11301

Add "byte order mark" to the export CSV file

Added by Alexey Korchuganov over 5 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:-% Done:

0%

Category:I18n
Target version:-
Resolution:

Description

I would like to suggest adding a possibility of inserting "byte order mark" to the export CSV file. These bytes make life of windows users slightly easier, because the most of Windows* programs do not use UTF-8 as default charset for text files, so they cannot parse UTF-8 file correctly if use non english text. And users have to choose encoding manyally.

I would not like to suggest hard coding, because there are some limitations, several are described here: http://en.wikipedia.org/wiki/UTF-8#Byte_order_mark
I think, the right way is: to add an option which will control of inserting these bytes

following example of hard coding for my istallation
based on changeset: 9852:4e40d59645ea
tag: tip
user: jplang
date: Wed Jun 20 19:24:58 2012 +0000

diff:
--- a/app/helpers/issues_helper.rb Tue Jun 19 02:11:16 2012 0000
++ b/app/helpers/issues_helper.rb Mon Jul 02 12:53:55 2012 +0400
@ -322,7 +322,7 @

export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
  # csv header fields
- csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) }
csv << [[ 0xEF, 0xBB, 0xBF, 35 ].pack("c*") ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
(options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])

Thank you
Alexey


Related issues

Duplicates Redmine - Feature #7037: CSV export encoding and excel. UTF-8 and BOM Closed 2010-12-03

History

#1 Updated by Alexey Korchuganov over 5 years ago

diff was wrapped to the pre tags

diff -r 5f01bbee74d7 app/helpers/issues_helper.rb
--- a/app/helpers/issues_helper.rb      Tue Jun 19 02:11:16 2012 +0000
+++ b/app/helpers/issues_helper.rb      Mon Jul 02 12:53:55 2012 +0400
@@ -322,7 +322,7 @@

     export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
       # csv header fields
-      csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
+      csv << [[ 0xEF, 0xBB, 0xBF, 35 ].pack("c*") ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
         (options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])

#2 Updated by Go MAEDA over 2 years ago

  • Status changed from New to Closed

Duplicate of #7037 and implemented in Redmine 3.1.0.

#3 Updated by Go MAEDA over 2 years ago

  • Duplicates Feature #7037: CSV export encoding and excel. UTF-8 and BOM added

Also available in: Atom PDF