end
def fix_text_encoding(txt)
+ txt ||= ''
if txt.respond_to?(:force_encoding)
txt.force_encoding('UTF-8')
txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
@ic.iconv(txt)
rescue
txt
- end || ''
+ end
end
# 0x5c char handling
txt.gsub(/\\/, "\\\\\\\\")
class PdfTest < ActiveSupport::TestCase
include Redmine::I18n
+ def test_fix_text_encoding_nil
+ set_language_if_valid 'ja'
+ pdf = Redmine::Export::PDF::IFPDF.new('ja')
+ assert pdf
+ assert_equal '', pdf.fix_text_encoding(nil)
+ end
+
def test_fix_text_encoding_backslash_ascii
set_language_if_valid 'ja'
pdf = Redmine::Export::PDF::IFPDF.new('ja')