Android Question chr 27 and 16 what are mean


Licensed User


Active Member
Licensed User
The end result of these characters, what is means?


Well-Known Member
Licensed User
The end result of these characters, what is means?
It is a command to the printer to do something. There are several common printer control sets ("languages"), generally one from each of the major printer manufacturers. This command is from the Epson Standard Code for Printers (ESC/P). Two other major printer control languages are HP's Printer Command Language (PCL) and Adobe's Postscript (PS).

In ESC/P, most commands start with an Escape character (ASCII code 27) which is a control code that lets the printer know that what comes next should be interpreted as a command, rather than be printed. The next character indicates the command: your example is the letter "t" which is the "select character code page" command, per this randomly chosen reference from the internet:


I realised afterwards that this example also demonstrates that the internet makes mistakes: first I spotted that the Parameter range is supposedly 0 <= n <= 15 when clearly there are examples all the way up to 255, and second I spotted that the ASCII rendition of the command is ".t" (incorrect) rather than just "t" (correct). Usually it pays off to double-check information by finding multiple different sources that confirm each other. Added benefit is that the sources will be written in different styles, and one of those styles will align best with you. Often, extra time taken during searching is reclaimed during reading ;-)

So, in summary: your code:
Chr(27) & "t" & Chr(16)
is a command to a printer, comprised of three characters:

1/ Escape = ASCII 27 = "this is a command"
2/ "t" = ASCII 116 = Epson printer command to select which set of characters to use for printing
3/ character# 16 = one-byte parameter to specify the character set; here it is WPC1252 "probably the most-used 8-bit character encoding in the world"

Ideally, the code fragment you supplied would have been part of something like:
Dim PrinterCommand As String = Chr(27) & "t" & Chr(16)    'select character set Windows 1252
PrintString(SalesPrinter, PrinterCommand)
but sadly, writing readable code is a bit of a dying art, and more probably you had something like:
posdevxmit(shared.default.outlocal[1], Chr(27) & "t" & Chr(16))
Last edited: