ASCII Conversions (I think)

Posted on 2004-03-28
Last Modified: 2012-06-21
This is what I believe to be a ASCII string that in my system at work represents a F7 (I think)

00000000  1b 62 0d                                         .b.

How can I tell what characters this transalates to in

such Chr(27) & Chr(79) & Chr(83)

I know this is not right but it is an example.
Question by:scorpion53061
LVL 48

Expert Comment

ID: 10697713
Your question is not clear, can you give mode details?

Expert Comment

ID: 10697734
Some remarks :
You have the Keys class. There you will find all the possible key the user may type. Then you can use the Asc or AscW method to get a ASCII value
Otherwise, you also have several constants you can use in string :


Author Comment

ID: 10698410
ok what I need to do is send this string as a telnet command. This is a hex dump log.

00000000  1b 62 0d                                         .b.

and what is suppose to happen is that this will result in the F2 key actions being performed.

are you saying I can say

Telnet1.Send(Chr(&H00000000  1b 62 0d                                         .b.))

and this will work?
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

LVL 12

Expert Comment

ID: 10698920
>    00000000  1b 62 0d                                         .b.
To me, this looks like a typically hex dump.
The 00000000 represents the address.  All zeros indicates the begining of the file.
The 1b 62 0d is the hex representation of the data.
The .b. is the character representation of the data, where the dots represent unprintable characters.

Therefore, I believe you only need to send the 1b 62 0d.

I'm unfamiliar with your Telnet control, but assuming that the Send method can take a Byte array, you could use the following.

        Dim bytes As Byte() = {&H1B, &H62, &HD}

Those bytes happen to have decimal values of 27, 98, and 13.  I got those values by putting a breakpoint on the Telnet1.Send line, and running to that line.  Then, while still in debug mode, I looked in the locals window (or menu Debug / Windows / Locals ).  
Hex 0d (dec 13) represents a carriage return, which makes sense at the end of a line.

Author Comment

ID: 10699159
I see what you are thinking but it didn't work for some reason it didnt work. I got a weird looking character.

This did work for F7

Telnet1.Send(Chr(27) & "[18~")

now why which is what is bugging me (I saw this in the raw data of the emulator) I don't have a clue.

The problem I am going nuts on is that what htey are calling F11 is the same as what htey are calling F5 and it is making F5 of course do F11' functions.

Lets do this. Do you know how I might say

(ShiftKey? & Chr(27) & "[23~")

"[23~" is the F11 code but I am oging to add a shift key to it to see if it changes the raw data.

LVL 12

Expert Comment

ID: 10700059
(1) Those look like VT-??? codes for the keys.
Often a device is emulating a particular VT-terminal-type.  Is your device doing this?
Are you supposed to be using one particular terminal emulation with telnet to communicate with your device?  Which one? (This will help a lot.)

(I'm not saying it is, but ...)
If it's VT-320 emulation, see
Cryptic, isn't it!  It's not really as bad as it first looks.
Chunk it in blocks delimited by the colon ":" character.
For example:
The k3 key sends \EOR, where \EOS means ESC "O" "R", then
the k4 key sends \EOS, where \EOS means ESC "O" "S",  then
the k6 key sends \E[17~, where \E[17~ means ESC "[17~", etc.
I think k1-k9 correspond to F1-F9, and k0 to k10, but I don't know what keyname corresponds to F11.
Maybe kI corresponds to F11, but I really don't know.
ESC is the same as Chr(27) in VB.NET.  From that info, it's pretty easy to write the VB.NET code.

(2) The codes sent for each F-key are configurable.  This explains how F5 and F11 can be the same.

(3) Make a clear distinction between (a) a keypress, and (b) the data sent over the wire for that key.  They are very different things.


If this worked for F7:
  Telnet1.Send(Chr(27) & "[18~")
and if the correct code for F11 is 23, then this should work for F11:
  Telnet1.Send(Chr(27) & "[23~")

The shift key has nothing to do with the data sent.  Shift-key is for input, not data transmission.
On the other hand, the shift key may (and probably does) cause the shift-F11 keypress to generate a different sequence, so maybe 23 is not right for shift-F11.  I suspect that ESC "[23~" is NOT the code the device is expecting for shift-F11. In other words, the codes sent for F11 can be completely different from the codes sent for shift-F11.


Author Comment

ID: 10700287
Yeah this is a ibm3151 system and the control uses vt100. I have been successful thus far in manipulating the situation to adapt to the 3151 by mimicing a vt240 terminal.

THe one lone stumbling block is F5.

I can communicate "F5" to the emulator by saying

Telnet1.Send(Chr(27) & Chr(101) & Chr(13)

but I cannot anticipate it in my case statement like I did the others so I can build waitfor and statements as such.

The one lead I have on this is "\27m" but I do not know how to say

Case Chr(27) & "m"   'F5 - does not work
                    Telnet1.Send(Chr(27) & "m")
also tried
Telnet1.Send(Chr(27) & Chr(101) & Chr(13)

Thank you much for your help. You seem to know your way around this stuff. I didnt think I would find anybody.

On the F11 situation this is what I came up with

Case Chr(27) & "[28~"   'what is being received when F11 is hit
                    Telnet1.Send(Chr(27) & "[23~") 'I send this and F11 functions perform. Again I do not know why.

Author Comment

ID: 10700307

it is the same as F10. Now what do I do.....
Case Chr(27) & "[21~"   'F10
                    Telnet1.Send(Chr(27) & "[21~")
LVL 12

Expert Comment

ID: 10700401
> the control uses vt100
You mean Telnet1 ?
Can you configure Telnet1 to emulate the VT240.
All these codes you need should be in the documentation for the VT240 or the the Telnet1 control.
ASCII table:

>  You seem to know your way around this stuff.
Not as much as it might seem.  I'm dredging a little up from my memory of many years ago.

It looks like you have the Telnet1.Send() and the Chr() down.  That takes care of how to send things.
Now all you need to do is find the right codes to send.

--- F5 ---
  Chr(27) & Chr(101) & Chr(13)    is equivalent to ESC "e" CR
but you talk about ESC "m"
That's inconsistent.  Why?

--- F11 ---
> 'I send this and F11 functions perform. Again I do not know why.
it's probably because the terminal you're sending to is emulating a different terminal type than the terminal you're typing at.  Therefore the codes sent by the keys are different.


> it is the same as F10.
Are you saying that both F5 and F10, when pressed on your terminal send the same code?
Are you also implying that the code you need to send to the remote terminal are different for F5 and F10?
If so, it seems like you'll need to either (1) use a different emulator you're typing into, (2) find a way to configure to redefine what that key sends, or (3) find/write something else to do the appropriate terminal emulation.

Author Comment

ID: 10700426
No I am afraid I cannot switch to that emulation I am afraid. For whatever reason it does nto work.


towards the bottom of the page and it shows F5 and F10 being the same. The hex value it gives returns to [21~  which works great for F10 but not with F5.

This is a little maddening. I am trying to get my people off of ibm3151.

Author Comment

ID: 10700448

middle of page gives the \27m value
LVL 12

Expert Comment

ID: 10701930
In your link
I don't see that it says F5 and F10 are the same.
It makes a distinction between the "VT" column which has F1 thru F15 and the "Key Name" column which has a F6 thru F20 in parentheses.  Which of these naming conventions is useful to you?  I'm assuming the VT column, because you keep mentioning F5, which doesn't exist at all in the "Key Name" column.

Using the VT names:

F5    ===>   9B 32 31 7E
                     CSI 2 1 ~
F10   ===>   9B 32 38 7E
                     CSI 2 8 ~

Author Comment

ID: 10705896
Ok lets really make this simple....

\27[17~ Is written like this:

Chr(27) & "[17~"

How would this be written:

LVL 12

Accepted Solution

farsight earned 500 total points
ID: 10708403
Chr(27) & "m"
LVL 12

Expert Comment

ID: 10708439
Perhaps it would be more meaningful to define a constant or variable once, and use it often.
Dim ESC As String = Chr(27)

then use

ESC & "[17~"
ESC & "m"

Author Comment

ID: 10740012
I need to send this keystroke to a application. This came from ethereal. Here is its value in "Hex Dump"

00000000  1b 65 0d                                         .e.

Here is its value in ASCII


Here is its value in EBCDIC


Here is its value in "C Arrays". I am not exactly sure what they mean here.

char peer0_0[] = {
0x1b, 0x65, 0x0d };

Does anyone know how I might utilize this to send what I need to in my windows app?
LVL 12

Expert Comment

ID: 10740488
If you need to "send this keystroke to a application", you would use SendKeys().

Read tomazsr's last comment in this question:

Here are several different alternatives you could use to create the string to send.
Use any one.  I prefer Option 4.

        ' The key sequence is: ESC e carriage-return
        Dim keys As String = Chr(&H1B) & Chr(&H65) & Chr(&HD)                                          ' Option 1

        Dim keys As String = Chr(&H1B) & "e" & vbCr                                                            ' Option 2

        ' If you have Imports Microsoft.VisualBasic (Included by default for VB projects)
        Const ESC As String = Chr(&H1B)
        Dim keys As String = ESC & "e" & vbCr                                                                      ' Option 3

        'If you have Imports System.Windows.Forms (Included by default for Windows Forms projects)
        Dim keys As String = Keys.Escape & "e" & Keys.Enter                                                  ' Option 4

Then use this line as shown in the link at the top.

Here's a nicer ASCII table.

Author Comment

ID: 10808461
I don't think there is an answer but this needed to get closed.

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question