printing 0x00 in ascii



 DEVELOP > c-Plus-Plus > printing 0x00 in ascii

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Joseph Suprenant"
Date: 19 Nov 2003 09:28:27 PM
Object: printing 0x00 in ascii
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
.

User: "Ivan Vecerina"

Title: Re: printing 0x00 in ascii 20 Nov 2003 12:53:01 AM
"Joseph Suprenant" <laclac01@yahoo.com> wrote in message
news:vxWub.126606$ZC4.82041@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
.

User: "Victor Bazarov"

Title: Re: printing 0x00 in ascii 19 Nov 2003 11:06:34 PM
"Joseph Suprenant" <laclac01@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
.

User: "Noah Roberts"

Title: Re: printing 0x00 in ascii 20 Nov 2003 03:26:02 PM
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
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER