1

I want to convert the hex value of an ASCII control character to its acronym. For example: 1C (the code for the File Separator character) becomes FS. How can I do this in C++?

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
Ershad
  • 947
  • 2
  • 20
  • 40
  • may be telling the rule you want to use would help. Having the code of your first attempt would help too. – Felice Pollano Nov 18 '11 at 12:00
  • sorry guys, it was very urgent, i am trying my best to convert HEX to SYMBOL, Thanks – Ershad Nov 18 '11 at 12:03
  • You'll need to define "SYMBOL". What is FS and how do you get from 1C to FS? How would 1B be displayed? – Graeme Perrow Nov 18 '11 at 12:04
  • Aha, you mean as in "FS" the ASCII character. I don't know if there's a standard function to do this, but it shouldn't be very tricky to write a simple function to do the conversion for you (perhaps based around a switch-case or a lookup table). – Oliver Charlesworth Nov 18 '11 at 12:07
  • 3
    @Ershad: No offense, but no one really cares that it is "urgent". Also, when asked for more information, repeating the exact same question as a comment **won't help**. If it was poorly written the first time, it won't get any better the second one. – ereOn Nov 18 '11 at 12:10
  • 4
    There's an Spanish saying: *Vísteme despacio que tengo prisa* (*Dress me slowly, I am in a hurry*). If you are in a hurry, the best thing that you can do is take the time to write the question so that it will have greater chances of getting an answer. This is extensible to your comment: if people have doubts about what you are asking, take the time to clear de doubts, as that will probably get you closer to an answer sooner. – David Rodríguez - dribeas Nov 18 '11 at 12:17

2 Answers2

2

Wikipedia: http://en.wikipedia.org/wiki/C0_and_C1_control_codes

You can use a simple lookup table, an array, to quickly find the ASCII name of a character code. Or you can use a big switch (not recommended). Anyway you will have specify the names in your source code that defines that array.

Why could you not mention "ASCII" so that also the less experienced SO users could guess what you were talking about (note that when they don't recognize anything or can't think of an answer, they usually vote to close the question)?

halfer
  • 19,824
  • 17
  • 99
  • 186
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
0

I think you are looking for an disassembler engine, such as beaengine.

Necrolis
  • 25,836
  • 3
  • 63
  • 101