473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Jul 22 '05 #1
3 10703
"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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Brad Tilley | last post by:
I'm printing some info into a txt file that will be uploaded into a MySQL DB. I use ';' as field separaters. How can I stop spaces from appearing on both sides of the ';' When I do this: ...
11
by: Marian Aldenhövel | last post by:
Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain...
1
by: Ralph Noble | last post by:
Folks ... I have a pipe-delimited ASCII text file with a lot of different non-printing characters. Rather than try and figure out all the non-printing characters that exist in this 17+ million...
3
by: Ahmad Abu-Raddad | last post by:
Hey Guys, Does anyone knows of a way to print HTML source directly to the printer (Server Side)?. I tried the PrintDocument class and the e.Graphics.DrawString and e.Graphics.DrawImage() but...
6
by: jasn | last post by:
Hello I am getting the following error message when I try and send an XML sting to a web service, I read somewhere that most web services prefer ascii and some throw errors when using unicode so...
29
by: Ron Garret | last post by:
>>> u'\xbd' u'\xbd' >>> print _ Traceback (most recent call last): File "<stdin>", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in position 0: ordinal not in...
25
by: mdh | last post by:
I wrote a little insignificant program, to help me write a more significant one!!...that was supposed to print all Ascii values from 0 to 127: >>>> #include <stdio.h> # define UPPER_LIMT 127...
5
by: Ross | last post by:
I have a quick question regarding printing string constants. When you printf() a string constant, how are the characters encoded that get sent to the standard output? Is it in the execution...
14
by: abhishekkarnik | last post by:
Hi, I am trying to read an exe file and print it out character by character in hexadecimal format. The file goes something like this in hexadecimal 0x4d 0x5a 0x90 0x00 0x03 .... so on When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.