0

Do you have any algorithms I can look at that will perform escape logic on a base64 and hex encoded message? Thanks

2
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by alan_b
0

I apologize. My initial post was not very clear. I have an ascii string that contains escape sequences in their Hex representation. I need to handle these Hex escape sequences and need an algorithm that will do this. For example, if I ahve the following string

My name is John \7C.

I want to be able to escape the \7C and replace it with its ascii representation which is a |

If you have an algorithm that can process Hex escape sequences, that would be great...

Thanks

0

shouldn't be difficult -- search for '\' and if found assume remaining word is a hext digit. you can use strtol() to convert to a long and typecast to char.

char *ptr;
char hex[] = "7C";
long n = strtol(hex,&ptr,16);
cout << (char)n;
//
// or to convert back to a string
char buf[255];
sprintf(buf,"My name is John %c", (char)n);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.