What encoding are you using? ASCII is a subset of UTF8 so it does not
need to be converted on Ruby 1.8, and is automatically converted on
1.9.
Also... please note that Ruby 1.8.7 is not (and will not be) support.
1.8.6 and 1.9.0_3 are the currently supported versions of Ruby for
Prawn.
-greg
--
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com
Oh, right. Are you using the builtin fonts? If so, the support for
ISO 8859-1 encoding[0] is broken. We have this fixed in master on
sandal/prawn, but I'll cut a 0.1.2 release with the changes in a
couple hours.
If you get a chance, please try the code in edge and see if it works
for you. If not, please try the release when it is ready and see if
it fixes your problem. I'll drop a note here when it is ready
-greg
That said, I run 1.8.7 on one of my boxes, and I haven't run into any
issues when running the prawn specs on it.
-- James Healy <jimmy-at-deefa-dot-com> Mon, 11 Aug 2008 22:43:35 +1000
In the meantime, you can try converting the string to utf-8 and loading
a truetype font. Almost any truetype font you can find on your system
should support the basic iso-8859-1 character set.
require 'iconv'
require 'prawn'
@iconv = Iconv.new('ISO-8859-1', 'utf-8')
Prawn::Document.generate("text.pdf") do |pdf|
pdf.font "some_font.ttf"
pdf.text @iconv.iconv("a latin1 string from your db")
end
-- James Healy <jimmy-at-deefa-dot-com> Mon, 11 Aug 2008 22:44:22 +1000
My bad, I got the order of arguments to the iconv constructor wrong. It
should be iconv = Iconv.new(to_encoding, from_encoding). In your case
you want to go from iso-8859-1 to utf-8.
The API docs for iconv are available at ruby-doc:
http://ruby-doc.org/stdlib/
-- James Healy <jimmy-at-deefa-dot-com> Mon, 11 Aug 2008 23:20:24 +1000