Android Question chr 27 and 16 what are mean

Discussion in 'Android Questions' started by HAH, Jul 11, 2019.

  1. HAH

    HAH Active Member Licensed User

    in this code link
    what this code means:
    Code:
    Chr(27)&"t"&Chr(16)
     
  2. DonManfred

    DonManfred Expert Licensed User

    It is noted in the same line!

    You need to check the documentation of your priinter to know the commands he understands.
     
    Peter Simpson and HAH like this.
  3. Brandsum

    Brandsum Active Member Licensed User

    [​IMG]
     
    emexes and HAH like this.
  4. HAH

    HAH Active Member Licensed User

    good @Brandsum
    What "t" in between mean?
     
  5. Brandsum

    Brandsum Active Member Licensed User

    Code:
    Chr(27)&"t"&Chr(16)

    ' This is similar to

    Chr(27) & Chr(116) & Chr(16)
     
    HAH likes this.
  6. HAH

    HAH Active Member Licensed User

    The end result of these characters, what is means?
     
  7. DonManfred

    DonManfred Expert Licensed User

    Check the documentation of the Printer @KMatle is using about what this ESC-Sequence means.
     
    HAH likes this.
  8. KMatle

    KMatle Expert Licensed User

    I can't remember :D Just some font formatting. It's printer specific. So just take a look at your printers manual.
     
  9. emexes

    emexes Well-Known Member Licensed User

    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:

    upload_2019-7-12_9-19-32.png

    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:
    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:
    Code:
    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:
    Code:
    posdevxmit(shared.default.outlocal[1], Chr(27) & "t" & Chr(16))
    Sigh.
     
    Last edited: Jul 12, 2019
    DonManfred and Brandsum like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice