Defect #117
closed
'\'(char code 0x5c) handling is improper in PDF output
Added by Go MAEDA about 17 years ago.
Updated about 17 years ago.
Description
When createing PDF file, '\' may have to be escaped like '\\'.
Redmine perhaps does not escape '\', so we sometimes get malformed output.
Because of this problem, issues which contains specific Japanese multi-byte character whose second byte character is
0x5c are not properly exported PDF file (gets malformed output).
[How to reproduce]
1. Create new issue. Description of the issue is following.
printf("Hello\n");
printf("World.\\n");
2. Export it to PDF. You will see malformed output like this.
printf("Hello ");
printf("World.\n");
Hi.
I make patch for this problem.
This one can resolve 2 problems:
A:Iconv can't convert multi-byte string include '\'.
B:multi-byte character include 0x5c can't show in PDF.
I check only environments:
WindowsXP SP2/Japanese
ruby 1.8.6-p110
rails 1.2.3
redmine rev.781
Index: ifpdf_helper.rb
=================================================================
==
--- ifpdf_helper.rb (Revision 781)
+++ ifpdf_helper.rb (Working copy)
@@ -53,7 +53,13 @@
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
@ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
txt = begin
- @ic.iconv(txt)
+ txtar = txt.split('\\')
+ txtar << '' if txt[-1] == ?\\
+ txtar2 = []
+ txtar.each{|x|
+ txtar2 << @ic.iconv(x)
+ }
+ txtar2.join('\\').gsub(/\\/, "\\\\\\\\")
rescue
txt
end
Your fix (slightly edited) is committed in r813.
Thanks for your help.
Thanks for your work. The fix is of great benefit to MBCS users.
Although the patch's author is Aruo Miura, my name is
written in svn commit log instead of Miura.
Oh, I'm sorry. I didn't notice that the patch was from someone
else.
Big thanks to Aruo Miura :-)
No problem.
Thanks for your work.
Also available in: Atom
PDF