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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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?
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parsing JSON help 1 26
Name Space error VS2015 1 38
Need to sort columns in DataGridView 4 41
ASP.NET Built-In Report Creator / Viewer 5 25
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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