diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-16 08:29:18 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-16 08:29:18 +0000 |
commit | 4a3581c748020a74b5b754f215a93c6f777d0ab3 (patch) | |
tree | 2ef0566002b7a52336885aefde5abbc245ec8868 /app | |
parent | 4b5d50e40a4907cdbd4efa9100dbb51c7e534e3f (diff) | |
download | redmine-4a3581c748020a74b5b754f215a93c6f777d0ab3.tar.gz redmine-4a3581c748020a74b5b754f215a93c6f777d0ab3.zip |
fix malformed time entry report csv encoding in case of unable to convert (#8549)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7820 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/timelog_helper.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 6b34e60b0..86acfe586 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -147,7 +147,9 @@ module TimelogHelper headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) } headers += periods headers << l(:label_total) - csv << headers.collect {|c| to_utf8(c) } + csv << headers.collect {|c| Redmine::CodesetUtil.from_utf8( + c.to_s, + l(:general_csv_encoding) ) } # Content report_criteria_to_csv(csv, criterias, periods, hours) # Total row @@ -169,7 +171,9 @@ module TimelogHelper hours_for_value = select_hours(hours, criterias[level], value) next if hours_for_value.empty? row = [''] * level - row << to_utf8(format_criteria_value(criterias[level], value)) + row << Redmine::CodesetUtil.from_utf8( + format_criteria_value(criterias[level], value).to_s, + l(:general_csv_encoding) ) row += [''] * (criterias.length - level - 1) total = 0 periods.each do |period| @@ -185,9 +189,4 @@ module TimelogHelper end end end - - def to_utf8(s) - @ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8') - begin; @ic.iconv(s.to_s); rescue; s.to_s; end - end end |