Our (rails) app is mainly utf-8, so we set kcode to u.
However, we need to generate pdfs using the cp1252 encoding, as the
FPDF library doesn’t have unicode support.
Translating strings work fine using iconv, but the library is using
sprintf internally, which blows up on non-utf8 characters.
Ok, so FPDF doesn’t support Unicode.
But you can only feed it utf-8 characters?
That’s the gist of it, at least when running ruby with kcode = ‘u’.
I replaced the 4 occurances of sprintf(“%X %s bbb”, X, txt) with
sprintf("%X “, X) + txt + " bbb”, which fixed our issues.
Reasonable approach, or is there a better way?
Isak
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.