Rails messing up FPDF / encodings?

This code seems to break under rails and the console (1.2.2 branch),
while working as expected under irb:


require “fpdf/fpdf”

s = ("" << 73 << 241 << 116 << 234 << 114 << 110 << 228 << 116 << 105
<< 111 << 110 << 97 << 108 << 105 << 122 << 230 << 116 << 105 << 248
<< 110)

pdf = FPDF.new
pdf.AddPage
pdf.SetFont(“Arial”, “B”, 16)
pdf.Cell(40, 10, s)
pdf.Output(“test.pdf”)


The string should be valid cp1252, which afaik is also the default
encoding for fpdf.

Running this code from irb creates a pdf containing the whole string,
while trying to write the same string from within Rails or running
this code in script/console chops off the last two characters…?

Any suggestions appreciated.

Isak

On 3/7/07, Isak H. [email protected] wrote:

pdf.AddPage

Any suggestions appreciated.

Isak

Did some debugging on this issue, and found that my strings are
getting mutilated by sprintf, which fpdf is using for string
substitution, i.e. this is a kcode/ruby issue, and has nothing to do
with rails.

Taking the discussion to comp.lang.ruby instead, thanks.

Isak