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