Tuesday, January 5, 2010

Re: Printing with utf-8 characters on Windows

On Tue, Jan 05, 2010 at 11:39:44AM EST, Benjamin R. Haskell wrote:
> On Tue, 5 Jan 2010, Chris Jones wrote:

[..]

> > Since utf-8 is the default encoding on debian Lenny, I find it hard
> > to believe that the Vim to Postscript implementation would not
> > function out of the box with utf-8 encoded files,

[..]

> Printing UTF-8 text is hard, since PostScript doesn't support it
> natively.

Actually, since this is rather messy and I'm probably not going to take
another a look at it for some time, I decided to write my own personal
mini-howto on the subject, and since I was unable to quickly think of a
short elegant preamble, I wrote: "Printing UTF8-encoded files is tricky
at best.." ;-)

> I was pretty surprised that 'enscript' never made it into the
> Unicode age. 'paps' is the only thing I found that seems to do a
> reasonable job. Though, just now (while trying to find the page I found
> yesterday) I found a few entries in a UTF-8 and Unicode FAQ under
> 'Printing'[1].
>
> [1] http://www.cl.cam.ac.uk/~mgk25/unicode.html

Saw that too.. Nothing helpful.

> CUPS supposedly handles UTF-8 via the texttops filter, but I was unable
> to get anything reasonable (even fiddling with 'CHARSET=' and '-o
> document-format=text/plain;charset=' options). I eventually gave up and
> replaced /usr/libexec/cups/filter/texttops with the following script:

Went down that road, only to reach the same dead end.

> #!/bin/sh
> paps < "$6" | title="$3" perl -lpwe 's/stdin/$ENV{title}/ if 2==$.'

[..]

> > Can anyone shed some light on this mattter?

> From the docs, printexpr only affects how the generated PS temp file
> gets printed. So, if Vim's already subbing out the chars in the PS,
> it's not going to matter what happens next.

Pretty much what I speculated.

> Testing with :ha > test.ps shows that no matter what encoding or
> fileencoding or printencoding or printmbencoding I tried, it still
> shows up as latin1 in the resulting PostScript. Which is weird
> considering the various charset handling that appears to be done in
> src/hardcopy.c.

I was expecting to find a bug report somewhere, or would that be a Vim
enhancement request - i.e. lifting this limitation, and saw nothing.

> The only way I was able to get decent printouts was by just shelling
> out to paps:

> :!paps < % > test.ps

Looks like I was on the right track re: the OP's problem then, and one
variation or other involving paps should fix it for him.

Thank you for your comments,

CJ

No comments: