By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

printing 0x00 in ascii

P: n/a
Quick question hope someone can help.
I am sending a file accross a radio, i am limited to using only chars. I
get all the data on the receiving end but everytime it gets a 0x00 it is
treated as a 0x20 (ascii whitespace). SO when i go to print it out and view
my file my file is messed up just a little bit. Anyone have any ideas?
let me know
joe
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Joseph Suprenant" <la******@yahoo.com> wrote...
Quick question hope someone can help.
I am sending a file accross a radio, i am limited to using only chars. I
get all the data on the receiving end but everytime it gets a 0x00 it is
treated as a 0x20 (ascii whitespace). SO when i go to print it out and view my file my file is messed up just a little bit. Anyone have any ideas?
let me know


(a) What character is _printed_ when a certain char value is
spooled down the output stream is implementation- and platform-
defined. The language cannot dictate that.

(b) What do you expect your program should do? Why do you say
"it is treated as a 0x20"? Treated by whom or by what? What
is that mysterious "it" that "gets a 0x00"?

Victor
Jul 22 '05 #2

P: n/a
"Joseph Suprenant" <la******@yahoo.com> wrote in message
news:vx********************@twister.nyroc.rr.com.. .
| Quick question hope someone can help.
| I am sending a file accross a radio, i am limited to using only chars. I
| get all the data on the receiving end but everytime it gets a 0x00 it is
| treated as a 0x20 (ascii whitespace). SO when i go to print it out and
view
| my file my file is messed up just a little bit. Anyone have any ideas?

Maybe your transmission system does not support sending a 0x00,
so some code automatically replaces it with a 0x20.
What you could do is to somehow encode your data to avoid occurrences
of 0x00, or use a filter to generate escaped character sequences.
For example, using '/' as an escape character:

on the sending end:
switch( charToBeSent ) {
case 0x00: send('/'); send('z'); break;
// ... more escaped chars ...
case '/' : send('/'); send('/'); break;
default: send(charToBeSent); break;
}

on the receiving end:
char received = read();
if( received =='/' ) {
received = read(); // get next character
switch( received ) {
case 'z' : received = 0x00;
// ... more escaped chars ...
case '/' : /* -> ok: same char */
default: break;
}
}
hth-Ivan
--
http://ivan.vecerina.com
Jul 22 '05 #3

P: n/a
Joseph Suprenant wrote:
Quick question hope someone can help.
I am sending a file accross a radio, i am limited to using only chars. I
get all the data on the receiving end but everytime it gets a 0x00
I am assuming you are sending binary data because 0x00 would not appear
in a text stream.

it is treated as a 0x20 (ascii whitespace). SO when i go to print it out and view
my file my file is messed up just a little bit. Anyone have any ideas?
let me know


Try Base64. There is an RFC.

NR

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.