I want to print a file using a command like cat filename > /dev/lp0
where the file contains characters like ùàç
encoded in UTF-8. Is this is possible or do I need to use CUPS?
I'm using an embedded Linux with a Debian file system and 3.10 kernel version.
The printer is an Epson SX525WD connected with USB, but the system and CUPS detected this like a parallel printer /dev/lp0
. The CUPS version installed is 1.5.3, and when I try to print the file with lp command it returns:
lp: Unsupported document-format "text/plain"
So I have to use -oraw
to print and it doesn't print UTF-8 characters.
3 Answers 3
Yes that is possible. You can directly cat
a file to a printer like that and go around using CUPS.
Whether the result is what you expect depends on the content of the file and the make and model of the printer.
Here is a small shell script I use since more than 20 years for old
printers who don't manage UTF-8 ( source pr8.sh
, installed as /opt/bin/pr8
) :
#!/bin/sh
case 1ドル in
-r) opts="1ドル"
shift
;;
esac
cat "$@" |
iconv --unicode-subst="_" -f utf-8 -t iso-8859-1 |
enscript ${opts:+${opts}}
For more recent printers it's much easier, just use lpr
:
lpr my_file.txt
Use enca,and find
Install enca
$apt-get install enca
execute below command
$ enca filename
-
Thank you for the reply, when I execute "enca filename" returns: enca: Language `it' is unknown or not supported.Memphis– Memphis2014年09月12日 12:02:45 +00:00Commented Sep 12, 2014 at 12:02
-
2
enca
can detect a file's encoding, but that isn't the problem here. The problem is to convert UTF-8 text to the unspecified format expected by the printer.Gilles 'SO- stop being evil'– Gilles 'SO- stop being evil'2014年09月13日 23:10:14 +00:00Commented Sep 13, 2014 at 23:10