]> source.dussan.org Git - redmine.git/commitdiff
PDF: replace converting error characters instead of returning UTF-8 in FPDF ANSI...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 6 Apr 2011 10:50:01 +0000 (10:50 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 6 Apr 2011 10:50:01 +0000 (10:50 +0000)
In Japan, UTF-8 characters in Shift_JIS(CP932) becomes garbling(MOJI-BAKE).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5351 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/export/pdf.rb

index 5ea33e3a89727d95e14f02a99e51bc34ebcf0963..3115b8b0c0a8b042334f947e96def55d74f569a5 100644 (file)
@@ -151,11 +151,17 @@ module Redmine
             txt.force_encoding('ASCII-8BIT')
           else
             @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
-            txt = begin
-              @ic.iconv(txt)
+            txtar = ""
+            begin
+              txtar += @ic.iconv(txt)
+            rescue Iconv::IllegalSequence
+              txtar += $!.success
+              txt = '?' + $!.failed[1,$!.failed.length]
+              retry
             rescue
-              txt
+              txtar += $!.success
             end
+            txt = txtar
           end
           # 0x5c char handling
           txt.gsub(/\\/, "\\\\\\\\")