473,499 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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ÎÝ`
µx¼V§Q΢" .

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 5706

<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ÎÝ`
µx¼V§Q΢" .

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ÎÝ`
µx¼V§Q΢" .

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ÎÝ`
µx¼V§Q΢" .

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ÎÝ`
µx¼V§Q΢" .
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ÎÝ`
µx¼V§Q΢" .
>
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ÎÝ`
µx¼V§Q΢" .

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ÎÝ`
µx¼V§Q΢" .

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5935
by: Alexander Eisenhuth | last post by:
Hallo all there, maby I don't see the forest because of all that trees, but : from struct import * # how can I convert f = float(0.5)
9
7987
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
8
5223
by: snacktime | last post by:
Is there a module that sets the parity of a string? I have an application that needs to communicate with a host using even parity So what I need is before sending the message, convert it from...
21
2531
by: Mike | last post by:
Hi, The example below shows that result of a marshaled data structure is nothing but a string >>> data = {2:'two', 3:'three'} >>> import marshal >>> bytes = marshal.dumps(data) >>>...
29
4221
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
6
2449
by: xkenneth | last post by:
Hi, I've been attempting to write a serial program in python. I talk to a custom designed bit of hardware that sends me back groups that are 2 bytes in length. When i recieve them using either...
8
2337
by: Richard Schulman | last post by:
The following program fragment works correctly with an ascii input file. But the file I actually want to process is Unicode (utf-16 encoding). The file must be Unicode rather than ASCII or...
1
1603
by: supercooper | last post by:
I have this string that is being returned from a query on a DBISAM database. The field must be some sort of blob, and when I connect to the database thru ODBC in MS Access, the field type comes...
3
11623
by: Andrew Lentvorski | last post by:
Basically, I'd like to use the ctypes module as a much more descriptive "struct" module. Is there a way to take a ctypes.Structure-based class and convert it to/from a binary string? Thanks,...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.