summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-09 06:45:40 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-09 06:45:40 +0000
commite25dd95389431dfb91e196b1351babd4ab11c52a (patch)
tree442bf4cb53c617fdf427a13e8345596bf17bd908 /lib
parenta5d528c6c2810d52a042571fdf8451538f8a26a5 (diff)
downloadredmine-e25dd95389431dfb91e196b1351babd4ab11c52a.tar.gz
redmine-e25dd95389431dfb91e196b1351babd4ab11c52a.zip
PDF: replace invalid sequence in converting if encoding destination is UTF-8 (#61, #8312).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5715 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/export/pdf.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index 2ca6deb5c..448f7273f 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -455,8 +455,12 @@ module Redmine
txt ||= ''
if txt.respond_to?(:force_encoding)
txt.force_encoding('UTF-8')
- txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
- :undef => :replace, :replace => '?')
+ if l(:general_pdf_encoding).upcase != 'UTF-8'
+ txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
+ :undef => :replace, :replace => '?')
+ else
+ txt = Redmine::CodesetUtil.replace_invalid_utf8(txt)
+ end
txt.force_encoding('ASCII-8BIT')
else
ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')