views:

62

answers:

5

There is a server which sends some data in Octet strings. For example it is sending

00405080065233E

like this, then I need to convert this into a string and store it into a buffer.

If I decode that converted string it has give the same 000405080065233E octet string again. How can I do this? Can anybody suggest some solution?

A: 

This looks like hex to me.

Or what is the E doing at the end of the string?

Trefex
A: 

I'm not too sure what you're asking here. What is the initial form of the data? Is it some sort of int type or an array of char's?

If you have a number and want to convert that to a character, do like so:

short number = 5;
char character = '0'+5;

which works by adding the ascii value of '0' to 5, since the numbers are in order. Repeat per character, and append to your desired string.

Adam Shiemke
A: 

If you really have the data in a string (your terms are not so clear to me) have a look into the strtol functions. There you may pass the base of your integers as a parameter.

Jens Gustedt
A: 

Don't understand the question, do you want to transform that number in ASCII characters?

I don't know, but maybe a cast would work:

int number = 00405080065233E;
char foo = (char)number;
aitorkun
A: 

What does it mean? Do you want to encrypt it and pass and then decrypt it? Check out cryptography

Praveen S