Print special characters in console - character-encoding

In my console (XP), the following line echo "áéíóú" in a utf-8 encoded file prints this:
├í├®├¡├│├║
Im not sure if this is something i have to handle in nim.

I am not sure if it works on Windows XP, but if you have Windows 8.1 your Nim code should be fine provided that in your console you change code page to UTF-8 with the following command:
chcp 65001
You need Lucida Console font too.
Keep in mind that in the Output window of Aporia editor you don't need to change anything in order to see the correct characters.

Related

How do I send output from the terminal to a text file in Visual Studio Code with the proper encoding?

I'm having issues sending output containing Unicode box-drawing characters to a text file.
The string ┌───top───┐ prints to the terminal fine using the print command. It also renders properly if I open and write directly to a file in my code.
However, if I pipe the terminal output into a text file using
<run command> > out.txt, I get the result
ΓöîΓöÇΓöÇΓöÇtopΓöÇΓöÇΓöÇΓöÉ
Everything else prints fine, but why doesn't it handle certain Unicode characters?
Is there a quick fix for this?

Android ESC/POS protocol printing in Cyrillic

I bought a no-name Android ESC/POS printer, it support Bluetooth. I need help in printing Cyrillic symbols in Windows-1251 charset. What I do first:
\x1B\x40 (ESC # to initialize printer)
\xD5\xD3\xC9\n (the text that I need to print, standard Windows-1251 symbols, but it shows me some abracadabra :))
I should say, that the charset is set to Windows-1251 on the printer (by the exe tool that comes with it)
Also I tried command \x1B\x74\x49 (it sets the Windows-1251 manually, but there is no effect). Any ideas what we can do with it? Thank you all.
You can try my app that print cyrillic text: https://play.google.com/store/apps/details?id=pe.diegoveloper.printerserverapp
Configure your ESC/POS printers on 'Quick Printer' and print from your app.
I tried many variants and after this manual end up with this character code page settings { 27, 116, 9 }
outputStream.write(new byte [] { 27, 116, 9 });
outputStream.write("Привет Мир".getBytes("cp866"));
outputStream.write(PrinterCommands.LF);
Try to convert your text to cp866.
And set code page in printer via ESC/POS command into 17.
With Universal Cyriclic decoder you can find your source encoding/decoding.
Enter in decoded field your output text. For example 袩褉懈胁械褌.
Select source encoding UTF-8.
Then find your wanted decoding charset by selecting field "display as".

How to print an excel document from command line with PRINT command in MSDOS

Im trying to print an excel document through a default printer configured from command prompt using PRINT command as shown below:
C:>print c:\printdocs\test1.xls
by typing above and pressing enter a line saying 'C:\test1.xls is currently being printed'
is getting displayed but the excel document is not sent for default printer for printing. Please help me with this, where iam going wrong.
print.exe is designed to print a text file, and nothing else. In fact, if you type print /? from a command prompt, it tells you that in the first line of the text:
C:\>print /?
Prints a text file.
PRINT [/D:device] [[drive:][path]filename[...]]
/D:device Specifies a print device.
So the answer to your question is that you can't print an Excel file via print from the command line, because an .XLS file isn't a text file.

What do I need to put in .emacs to print to default Windows printer?

I used to have postcript printing working perfectly in Emacs 21 in Windows+Cygwin, but after upgrading to Emacs 23, I am receiving the following error in the minibuffer:
Opening output file: invalid argument, C:/PDFCreator:
My current .emacs contain the current relevant statements:
(require 'ps-print)
(setq ps-spool-duplex t)
(setq ps-auto-font-detect nil)
(setq ps-print-color-p nil)
It used to have the following line as well:
(setq ps-lpr-command "qprt")
But it generates a similar error:
Searching for program: no such file or directory, qprt
Any idea what changed in Emacs 23 and how I can bring printing back to life?
(at this point I am only interested in printing to the default Windows printer, which is PDFCreator).
From the Emacs Wiki PrintingFromEmacs, the following configuration is recommended.
Where lpr is the Cygwin lpr version.
(setenv "PRINTER" "PDFCreator")
(cond ((eq system-type 'windows-nt)
(setq ps-printer-name "PDFCreator")
(setq ps-printer-name-option "-d")
(setq ps-lpr-command "/bin/lpr")))
You could also use the Ghostscript configuration there and select the PDFCreator printer from the popup. Adjusting your GS_LIB and your ghostscript binary location accordingly.
(setenv "GS_LIB" "e:/tools/GSTools/gs8.14/gs8.14/lib;e:/tools/GSTools/gs8.14/fonts")
(setq ps-lpr-command "e:/tools/GSTools/gs8.14/gs8.14/bin/gswin32c.exe")
(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2"))
(setq ps-printer-name t)
Note to users of PDFCreator - they now install a bunch of toolbars and take over your web browsers when you install it.
http://en.wikipedia.org/wiki/Pdfcreator#Adware_toolbar_controversy
I had PDFCreator working fine with Emacs, then I made the mistake of letting PDFCreator update itself. It redirected all my search queries to Bing, took over a bunch of browser settings, added toolbars, default landing pages etc. It took me about an hour to clean out all the junk it added.
I had the same symtom as the poster, but it wasn't because of any change in Emacs 23.
My printer is a postscript capable network printer.
First, my hostname had changed sligtly when my work computer was upgraded from Windows to Vista. I had to change one character accordingly:
From
(setq ps-printer-name "//evf4ce46ac4ad3/seki81050470cm")
to
(setq ps-printer-name "//e7f4ce46ac4ad3/seki81050470cm")
This changed the error message from
direct-print-region-helper: Opening output file: invalid argument, //evf4ce46ac4ad3/seki81050470cm
to
direct-print-region-helper: Opening output file: no such file or directory, //e7f4ce46ac4ad3/seki81050470cm
Then I had to enable sharing of the printer. This is found in
\\e7f4ce46ac4ad3\Printers
which probably can be found in a more generic way. \\%computername%\Printers didn't work for me; I don't know why.
Right-click on the printer icon, select Sharing and enable Share this printer, with a suitable printer name, preferably with no spaces in it.
This was enough to enable printing for me.

Offending Command error while Printing EPS

I am printing an EPS File generated with following credentials.
%-12345X#PJL JOB
#PJL ENTER LANGUAGE = POSTSCRIPT
%!PS-Adobe-3.0
%%Title: InvoiceDetail_combine
%%Creator: PScript5.dll Version 5.2.2
%%CreationDate: 10/7/2011 4:46:59
%%For: Administrator
%%BoundingBox: (atend)
%%Pages: (atend)
%%Orientation: Portrait
%%PageOrder: Special
%%DocumentNeededResources: (atend)
%%DocumentSuppliedResources: (atend)
%%DocumentData: Clean7Bit
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
%%LanguageLevel: 2
%%EndComments
While doing Selection Printing on Ricoh Afficio 2090 or any other drivers/printers get the following error printed on the sheets
ERROR: undefined
OFFENDING COMMAND: F4S47
Stack:
.
Kindly Review and suggest a turn around for the same as i am already stuck in this hell. I have tried to convert/extract in PS but all in vain. I am using gsview to Print and view these files.
This is the problem:
%%PageOrder: Special
A ps document with "Special" page order can NOT be re-ordered. You cannot do a selection or range with this file because it is broken for this use. You must reprocess the file using Distiller or ghostscript (ps2ps or ps2pdf) in order to print selected or re-ordered pages from the document.
You can avoid this by generating your postscript files with a real Postscript™ driver (one not created by Microsoft).
The GSView Documentation has more about this.
Previously:
This line ...
%%TargetDevice: (HP Color LaserJet 4500) (2014.200) 0
... tells us that the file was generated with HP printers as a target. So this really is not an EPS file. Because it's not Encapsulatable. To generate output on a printer the file has to execute the showpage operator, which is a no-no for EPS files.
So uncheck the EPS box (it's a big fat lie, anyway), and select (install) a Generic Postscript driver. If you need to send it to multiple makes of printer, the file needs to make as few assumptions about the printer as possible.
The first thing is that this is not a valid EPS file, as it has PJL attached at the front. Many PostScript printers will strip this off, but by no means all.
This probably is not the source of the problem.
There is no way to 'review' the problem as you have not supplied the complete PostScript program. Without that there is no way to tell what is actually wrong, the error message tells you that the interpreter encountered 'F4547' while trying to parse a token, and that this has not been defined as a routine.
Most likely the file is corrupt, either damaged in some way, or possibly it is a biinary file and has been transmitted by some process which does has done some kind of conversion (CR/LF is common). The offending command looks like its ASCIIHex encoded, so that may be a red herring.
If you want additional help, you are going to have to make the whole program available somewhere.

Resources