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