468,491 Members | 2,033 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

Passing String with \x00

Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?

Thanks !

Aug 18 '06 #1
8 4801

<ab*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?
Possible solutions:
1) send the hex digits, they're ASCII also...
2) don't use str*() use mem*(), i.e., if you're using strcmp() try memcmp()
instead...
3) don't send characters which are being "translated", convert them to an
unused character, perhaps by setting bit-7, look at strchr() or strpbrk()
etc...
Rod Pemberton
Aug 18 '06 #2

Rod Pemberton wrote:
<ab*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?

Possible solutions:
1) send the hex digits, they're ASCII also...
2) don't use str*() use mem*(), i.e., if you're using strcmp() try memcmp()
instead...
3) don't send characters which are being "translated", convert them to an
unused character, perhaps by setting bit-7, look at strchr() or strpbrk()
etc...
Rod Pemberton
Thanks for your help .
Tried 1st one . But the server application is written in a way that it
accepts it as a ascii string only .
And he comparision is not being done at my end . So I can't help it .

About the 3rd point . If I change one bit and send it as an unused
character ,.. won't it be misinterpreted as a ascii value of some other
hex digit ?

Aug 18 '06 #3

Rod Pemberton wrote:
<ab*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?

Possible solutions:
1) send the hex digits, they're ASCII also...
2) don't use str*() use mem*(), i.e., if you're using strcmp() try memcmp()
instead...
3) don't send characters which are being "translated", convert them to an
unused character, perhaps by setting bit-7, look at strchr() or strpbrk()
etc...
Rod Pemberton
Thanks for your help .
Tried 1st one . But the server application is written in a way that it
accepts it as an ascii string only .
And the comparision is not being done at my end . So I can't help it .

About the 3rd point . If I change one bit and send it as an unused
character ,.. won't it be misinterpreted as a ascii value of some other
hex digit ?

Aug 18 '06 #4
ab*****@gmail.com schrieb:
Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .
What's a 16bit ascii value? I don't think such a thing exists.
Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure .
Are you sure, that the newline and tabs are the problem? Perhaps you send
too few bytes or got the conversion wrong. We can't tell without seeing the
code.
Can anyone tell me if there is any
other way to send these characters ?
You should ask this in a group where your sockets API is ontopic, maybe in
a unix programming group.

--
Thomas
Aug 18 '06 #5
<ab*****@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>
Rod Pemberton wrote:
<ab*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi all ,
>
I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .
>
Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii
value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .
>
The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?
Possible solutions:
1) send the hex digits, they're ASCII also...
2) don't use str*() use mem*(), i.e., if you're using strcmp() try
memcmp()
instead...
3) don't send characters which are being "translated", convert them to
an
unused character, perhaps by setting bit-7, look at strchr() or
strpbrk()
etc...

Thanks for your help .
Tried 1st one . But the server application is written in a way that it
accepts it as an ascii string only .
2)
And the comparision is not being done at my end . So I can't help it .

About the 3rd point . If I change one bit and send it as an unused
character ,.. won't it be misinterpreted as a ascii value of some other
hex digit ?
If you can't change the code on the other end, then yes, it most likely will
"misinterpret" the ASCII...

From what I understood, "something" is translating tabs, nuls, newlines.
Since you apparently don't have control of both ends or software pieces of
this communication channel, the only other solution (that I see at the
moment) is to remove or route around the interfering or translating piece
(i.e., "something") of hardware or software between you and other end...
Sorry,

Rod Pemberton
Aug 18 '06 #6
2006-08-18 <11**********************@h48g2000cwc.googlegroups .com>,
ab*****@gmail.com wrote:
>
Rod Pemberton wrote:
><ab*****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.com...
Hi all ,

I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?

Possible solutions:
1) send the hex digits, they're ASCII also...
2) don't use str*() use mem*(), i.e., if you're using strcmp() try memcmp()
instead...
3) don't send characters which are being "translated", convert them to an
unused character, perhaps by setting bit-7, look at strchr() or strpbrk()
etc...
Rod Pemberton

Thanks for your help .
Tried 1st one . But the server application is written in a way that it
accepts it as a ascii string only .
In what way is a string of hex digits not "a ascii string"?
Aug 18 '06 #7

ab*****@gmail.com wrote:
>
I need to convert a 32 bit string containing hex digits like
"76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii
value like "v`
xVQ΢" .

Now the presence of Hex digits like "0a" ,"00" , "0b" whose ascii value
is New line , NULL , Tab respectively brings the rest of the string to
new line or put a tab in between .

The real problem is that the string gets compared at the server send ,
where the converted ascii value for the same String containing hex
digits is present . But because of this new lines and tabs the string
comparision results in failure . Can anyone tell me if there is any
other way to send these characters ?
Presumably then the set of characters represented by your hex digits do
not include the characters New Line, NULL, and Tab. If the algorithm
you are using to convert your hex digits into characters is creating
these characters, then the algorithm must be wrong.

You need to know what the mapping is between the set of hex digits and
the characters you need to send. You also need to understand the format
in which the other end expects to receive the characters. If you are
supposed to be sending 16-bit characters, each will typically be sent
as a pair of octets with each octet representing half of a 16 bit
character. In this case, you need to understand how the other end
expects to receive them - which half of each character it expects to
receive first.

No-one here can tell you what format your data starts out in, or what
format it needs to be in at the various points in this process, You
must derive that information from the requirements you have been given.
Once you understand what formats you need at each point, and what
algorithms to use to convert between them, we'll be able to help you
implement C code to do the conversions.

Aug 19 '06 #8
On Fri, 18 Aug 2006 23:01:59 UTC, Jordan Abel <ra****@random.yi.org>
wrote:
>
In what way is a string of hex digits not "a ascii string"?
No. You have an ASCI string with not printable characters inside, but
not a hex string.
That is a string of hex characters of 0 - 15 in printable form:
"01234567890abcdef"
Equals in ASCII to
0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37
0x38 0x39 0x41 0x42 0x43 0x44 0x45 0x46 0x00

But is is not a string of hex characters as you means. It is simply a
string of printable characters.

"\x01\x23\x45\x67\x89\xab\xcd\xef\x00"
is a string of binary hex characters of the numbers 0 - 15 dec. but
will not be printable, whereas 1 byte contains 2 numbers.

"\001\043\105\147\211\253\315\357\0"
the same in octal.
So when you have a real ASCII string you have to convert the binary
number to ASCII.
When you have to send binary data you will never use (f)printf() or
its family because that will interpret some binary data as ASCII
control sequences. You may use either frwite() or potc() onto an
binary stream, not a text stream.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
Aug 19 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Alexander Eisenhuth | last post: by
9 posts views Thread by John F Dutcher | last post: by
8 posts views Thread by snacktime | last post: by
21 posts views Thread by Mike | last post: by
29 posts views Thread by zoltan | last post: by
6 posts views Thread by xkenneth | last post: by
8 posts views Thread by Richard Schulman | last post: by
1 post views Thread by supercooper | last post: by
3 posts views Thread by Andrew Lentvorski | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.