6

I have problem with printing to postscript from Vim.

I'm, using utf-8 encoding with czech characters like 'ščřž' but in the output I get upside question mark instead of the correct characters.

vim --version

VIM - Vi IMproved 7.2

+iconv +multi_byte +postscript

printer settings:

set printoptions=paper:A4,duplex:off,collate:n,syntax:n

printer font: courier

Milan Leszkow
  • 61
  • 1
  • 2

3 Answers3

1

Rkulla, that's wrong. As regards your message, I've understood that if we don't set 'printencoding' vim will convert our message (utf-8) to 'latin1' and because of that we have problems. I think that's not true.

I printed file (with Cyrillic symbols) in vim with printencoding=utf-8 by :hardcopy I also get reverse question mark instead of the correct symbols. My settings: 1) printfont = utf-8 2) encoding = utf-8 3) fileencoding = utf-8. I think problem in PostScript. If you try to print something (for example with Cyrillic symbols) in console/terminal (not GUI) by lp/lpr you will get incorrect symbols (in place where Cyrillic). That's conversion problems from non-ASCII text to PostScript in terminal. Vim use printexpr and has default: printexpr=system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error. I don't know how to fix that. I read that's general Unix/Linux problems. But you should try rewrite printexpr for using a2ps, enscript or similar.

Mephi_stofel
  • 355
  • 2
  • 6
  • 15
1

Send the buffer to the browser by converting to HTML, then print from there:

:TOhtml | w | !open -a Safari %

For example I have this in vim: enter image description here

If I type

:ha

I get this: enter image description here

But when I send it to the browser I get this (with color scheme!):

enter image description here

I have this in my .vimrc, which deletes the new html buffer and stored file:

nnoremap <F2> <ESC> :TOhtml <bar> w <bar> !open -a Safari % <CR> <bar> ZQ <CR> <bar> execute '!rm %:p.html' <CR>
Rian Rizvi
  • 9,989
  • 2
  • 37
  • 33
0

Make sure your printer supports printing unicode characters. Try updating your drivers and going into the settings and turning on truetype fonts for printing or a similar option. As far as I know, Courier uses ASCII.

Typing :h printencoding turns up:

If 'printencoding' is empty or VIM cannot find the file then it will use 'encoding' (if VIM is compiled with |+multi_byte| and it is set an 8-bit encoding) to find the print character encoding file. If VIM is unable to find a character encoding file then it will use the "latin1" print character encoding file. When 'encoding' is set to a multi-byte encoding, VIM will try to convert characters to the printing encoding for printing (if 'printencoding' is empty then the conversion will be to latin1). Conversion to a printing encoding other than latin1 will require VIM to be compiled with the |+iconv| feature. If no conversion is possible then printing will fail. Any characters that cannot be converted will be replaced with upside down question marks. Four print character encoding files are provided to support default Mac, VMS, HPUX, and EBCDIC character encodings and are used by default on these platforms. Code page 1252 print character encoding is used by default on Windows and OS/2 platforms.

rkulla
  • 2,494
  • 1
  • 18
  • 16