is there any way to output these characters...???
They're called non-printable for a reason.
What did you expect to see?
--
Bartc
You're not able to print the non-printable?
Hmm ...
--
pete
Bartc wrote:
when i execute the same statement in windows a smiley will be
outputted.
> 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.....
Well, presumably it's called a non-printable character because it
doesn't have a printing representation.
What do you want to see if it's non-printable? Use `isprint` to
find out if its printable or not, then decide how you want to
display a non-printing character.
#include <ctype.h>
void printCharSomehow( unsigned char ch )
{
printf( (isprint( ch ) ? "'%c'" : "char(%d)"), ch );
}
--
'It changed the future .. and it changed us.' /Babylon 5/
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
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 <apoe...@wpsoftware.com>
To email me, change .net to .com in the above address.
please check the below link..i want to print those symbols..
http://didgood.com/programing/datatheory/ascii-0-127.gif
Please don't quote signatures. I snipped Chris' for you.
You do what you want, you need to change your printing
charset to ASCII. Whether this is possible is specific
to your implementation, as are details about how to do
so. /Why/ you would ever need to do so is debatable.
Sorry, but the chart at that URL does not show ASCII. Instead, it shows a
bastardized characterset made up by Microsoft (or perhaps IBM?) that
contains /some/ features in common with ASCII, but deviates greatly from
ASCII for characters with values less than 0x20.
Perhaps the environment you compile and execute in does not use this
Microsoft/IBM bastard characterset.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
> hello everyone..,
What part of "non-printable" do you not understand?
For what it's worth, ASCII is divided into three types of character:
1) printable characters, including the SPACE character
2) format effectors, like CARRIAGE RETURN, LINE FEED, FORM FEED, and TAB,
3) communications effectors, like START OF HEADER, START OF TEXT, and END
OF TEXT (all used in BSC/Bisync communications protocols), ESCAPE,
SHIFT IN, and SHIFT OUT (used to select alternate glyphs), DELETE,
SUBSTITUTE (used in data correction and recovery)
(Note: these are my terms for these characters. For the official terms,
please see either the ANSI "US-ASCII" standards, or the CCITT "7 bit
characterset" standards. These two standards are interchangable, and both
describe the characterset coloqually known as "ASCII".)
For the printable characters (0x20 through 0x7e), printf() should result in
a glyph being deposited onto the display media. For the "format effectors",
printf() should not "deposit a glyph", but should instead change the
position of the /next/ glyph according to the effector. And, finally, for
the "communications effectors", printf() should (for the most part) show
neither a glyph, nor reposition for the next glyph. (In fact, the display
behaviour will be implementation-defined, and outside the scope of C to
define or influence).
>
>
Which goes to show how much Microsoft follows standards. :-)
<snip>
> 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...
> 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
> Please don't quote signatures. I snipped Chris' for you.
While we're on the meta stuff, your newsreader is removing References:
headers. This is Not Good.
Richard
Character 1 was originally SOH control code. Windows text console will show
it as a smiley (as you've seen). Windows graphics will just show a blank.
It's anyone's guess what Linux will show. So use of these characters is
rather hit and miss.
You need to use unicode for this. I think 0x263A. Then figure out how to
show unicode using C+Linux. Or you could just use :-) :-)
--
Bartc
> "jt" <karthi...@gmail.com> wrote in message
> news:60ce8ed6-6d28-46f9...@r15g2000prd.googlegroups.com...
>>
>>
>> Bartc wrote:
>>
>>> "jt" <karthi...@gmail.com> wrote in message
>>>
news:223752f0-a7a1-48fd...@i20g2000prf.googlegroups.com...
>>> > 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.....
[snip]
>> when i execute the same statement in windows a smiley will be
>> outputted.
>
> Character 1 was originally SOH control code.
Which is the Bisync/BSC communications protocol "Start of Header" octet,
used to delimit the beginning of the BSC address (as opposed to the
beginning or ending of the data) in a bisync communications exchange. Since
ASCII was defined, SOH has been given other uses.
> Windows text console will
> show it as a smiley (as you've seen). Windows graphics will just show a
> blank. It's anyone's guess what Linux will show. So use of these
> characters is rather hit and miss.
For the most part, it is up to each execution environment to interpret these
characters by their own standards. Output 0x01 to a serial line connected
to a BSC/RJE device, and that device will expect a bisync address and data
frame to follow. Output to a Windows text console, and Windows will display
a glyph which is not part of the ASCII standard glyphs. To each his own ;-)
> You need to use unicode for this. I think 0x263A. Then figure out how to
> show unicode using C+Linux. Or you could just use :-) :-)
>
--
>please check the below link..i want to print those symbols..
>http://didgood.com/programing/datatheory/ascii-0-127.gif
I suggest a search term such as this in a google search:
linux dos glyph
That should get you started.
I think there is a typo in your refernce page. Character 096 should show
the glyph for the grave chacracter.
Trivia. Doing a similar thing on the Atari ST can produce a picture that
looks remarkably like Hugh Hefner smoking a pipe. A young Hugh Hefner. And
there is a glyph pair somewhere that can produce an integral sign, as in
integral calculus.
No, ASCII doesn't have a smiley at position 001. The cited table does
not accurately reflect the ASCII character set.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
You already did; it just didn't display the way you expected it to.
<OT>
Your system provides ways to see your program's output in printable form.
For example, try "./my_program | cat -A" or "./my_program | od -c".
</OT>
<WAY_OT>
I believe that's J.R. "Bob" Dobbs.
<http://en.wikipedia.org/wiki/J.R._Bob_Dobbs>
</WAY_OT>
> "osmium" <r124c...@comcast.net> writes:
> [...]
> > Trivia. Doing a similar thing on the Atari ST can produce a
> > picture that looks remarkably like Hugh Hefner smoking a pipe. A
> > young Hugh Hefner.
> [...]
>
> <WAY_OT>
> I believe that's J.R. "Bob" Dobbs.
> <http://en.wikipedia.org/wiki/J.R._Bob_Dobbs>
> </WAY_OT>
I have that picture (suitably magnified) on the door of my mini-fridge
in my cubicle. Bob watches over me. As long as he's still grinning, I
figure I must be ok.
Brian
Thanks. I'll switch back to slrn (I was using Evolution and having
all sorts of minor problems, but this one takes the cake.)
--
Andrew Poelstra apoe...@wpsoftware.com
To email me, use the above email addresss with .com set to .net
Thanks. I knew I was missing a couple of points, but I couldn't
remember which ones.
--
Andrew Poelstra apoe...@wpsoftware.com
> Keith Thompson wrote:
>
> > "osmium" <r124c...@comcast.net> writes:
> > > Trivia. Doing a similar thing on the Atari ST can produce a
> > > picture that looks remarkably like Hugh Hefner smoking a pipe. A
> > > young Hugh Hefner.
> >
> > <WAY_OT>
> > I believe that's J.R. "Bob" Dobbs.
> > <http://en.wikipedia.org/wiki/J.R._Bob_Dobbs>
> > </WAY_OT>
>
> I have that picture (suitably magnified) on the door of my mini-fridge
> in my cubicle. Bob watches over me. As long as he's still grinning, I
> figure I must be ok.
That's what you think. That's what They want you to think. But ponder
this... is he grinning _with_ you, or _about_ you?
Trust nobody, not even (nay, especially) those who seem trustworthy.
Hail Eris.
Richard