Connecting Tech Pros Worldwide Help | Site Map

Re: ASCII characters

Andrew Poelstra
Guest
 
Posts: n/a
#1: Sep 5 '08
On Fri, 2008-09-05 at 05:20 -0700, jt wrote:
Quote:
>
Bartc wrote:
>
Quote:
"jt" <karthiks.840@gmail.comwrote in message
news:223752f0-a7a1-48fd-9334-607a80bc61c4@i20g2000prf.googlegroups.com...
Quote:
hello everyone..,
i'm using ubuntu 8.04 OS. I'm not able to output the non-printable
ascii chatacters.
for eg.
printf("%c",1); // nothing is outputted.....
>
is there any way to output these characters...???
They're called non-printable for a reason.

What did you expect to see?
>
when i execute the same statement in windows a smiley will be
outputted.
Then I suppose this code only works on Windows. (And actually,
I don't even suppose /that/ for all Windows.) Your problem is
that different systems use different character sets, and your
code is critically dependent on a specific charset.

So, as a learning experience, it has been very valuable.

But in future, to write portable C code that will compile on
all different systems (at least, with minimal porting effort)
it is best to be charset-agnostic. Basically, the only thing
you can assume is that the characters '0', '1', ..., '9' are
contiguous in value. Everything else (IIRC) is allowed to
change from character set to character set.

HTH.

--
Andrew Poelstra <apoelstra@wpsoftware.com>
To email me, change .net to .com in the above address.

Richard Heathfield
Guest
 
Posts: n/a
#2: Sep 5 '08

re: Re: ASCII characters


Andrew Poelstra said:

<snip>
Quote:
But in future, to write portable C code that will compile on
all different systems (at least, with minimal porting effort)
it is best to be charset-agnostic.
I agree with this, but I left it in so I'd feel better about disagreeing
with...
Quote:
Basically, the only thing
you can assume is that the characters '0', '1', ..., '9' are
contiguous in value. Everything else (IIRC) is allowed to
change from character set to character set.
....this, because you can *also* assume that the null character is
all-bits-zero, and that every member of the required source character set
will have a positive value when stored in a char.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Andrew Poelstra
Guest
 
Posts: n/a
#3: Sep 6 '08

re: Re: ASCII characters


On 2008-09-05, Richard Heathfield <rjh@see.sig.invalidwrote:
Quote:
Andrew Poelstra said:
>
><snip>
>
Quote:
>But in future, to write portable C code that will compile on
>all different systems (at least, with minimal porting effort)
>it is best to be charset-agnostic.
>
I agree with this, but I left it in so I'd feel better about disagreeing
with...
>
Quote:
>Basically, the only thing
>you can assume is that the characters '0', '1', ..., '9' are
>contiguous in value. Everything else (IIRC) is allowed to
>change from character set to character set.
>
...this, because you can *also* assume that the null character is
all-bits-zero, and that every member of the required source character set
will have a positive value when stored in a char.
>
Thanks. I knew I was missing a couple of points, but I couldn't
remember which ones.

--
Andrew Poelstra apoelstra@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Closed Thread


Similar C / C++ bytes