summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-06 05:38:31 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-06 05:38:31 +0000
commita4bad1435912b7ada79961c6d889359b4991a1a5 (patch)
tree6343e4616e30e7b4630fd685de12d7d184cfba68
parent470ff0c6e5838e124704b28834a85005210a783f (diff)
downloadredmine-a4bad1435912b7ada79961c6d889359b4991a1a5.tar.gz
redmine-a4bad1435912b7ada79961c6d889359b4991a1a5.zip
PDF: Ruby 1.9 compatibility of '0x5c'(backslash) handling in FPDF ANSI (#61, #117).
Japanese Shift_JIS and Traditional Chinese Big5 have '0x5c'(backslash) problem. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5343 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/export/pdf.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index a7fd56aa8..55ab37da4 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -143,12 +143,19 @@ module Redmine
end
def fix_text_encoding(txt)
- @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
- txt = begin
- @ic.iconv(txt)
- rescue
- txt
- end || ''
+ if txt.respond_to?(:force_encoding)
+ txt.force_encoding('UTF-8')
+ txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
+ :undef => :replace, :replace => '?')
+ txt.force_encoding('ASCII-8BIT')
+ else
+ @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
+ txt = begin
+ @ic.iconv(txt)
+ rescue
+ txt
+ end || ''
+ end
# 0x5c char handling
txt.gsub(/\\/, "\\\\\\\\")
end