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

ASCII characters

P: n/a
jt
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...???
Sep 5 '08 #1
Share this Question
Share on Google+
14 Replies


P: n/a

"jt" <ka**********@gmail.comwrote in message
news:22**********************************@i20g2000 prf.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.....

is there any way to output these characters...???
They're called non-printable for a reason.

What did you expect to see?

--
Bartc

Sep 5 '08 #2

P: n/a
jt wrote:
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...???
You're not able to print the non-printable?
Hmm ...

--
pete
Sep 5 '08 #3

P: n/a
jt


Bartc wrote:
"jt" <ka**********@gmail.comwrote in message
news:22**********************************@i20g2000 prf.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.....

is there any way to output these characters...???

They're called non-printable for a reason.

What did you expect to see?

--
Bartc


when i execute the same statement in windows a smiley will be
outputted.
Sep 5 '08 #4

P: n/a
jt wrote:
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

Sep 5 '08 #5

P: n/a
jt
On Sep 5, 5:26*pm, Chris Dollin <chris.dol...@hp.comwrote:
jt wrote:
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
please check the below link..i want to print those symbols..
http://didgood.com/programing/datath...scii-0-127.gif
Sep 5 '08 #6

P: n/a
On September 5, 2008 08:07, in comp.lang.c, jt (ka**********@gmail.com)
wrote:
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...???
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).
--
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. ------
Sep 5 '08 #7

P: n/a
On September 5, 2008 08:20, in comp.lang.c, jt (ka**********@gmail.com)
wrote:
>

Bartc wrote:
>"jt" <ka**********@gmail.comwrote in message
news:22**********************************@i20g200 0prf.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.....

is there any way to output these characters...???

They're called non-printable for a reason.

What did you expect to see?

--
Bartc

when i execute the same statement in windows a smiley will be
outputted.
Which goes to show how much Microsoft follows standards. :-)

--
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. ------
Sep 5 '08 #8

P: n/a
"jt" <ka**********@gmail.comwrote in message
news:60**********************************@r15g2000 prd.googlegroups.com...
>

Bartc wrote:
>"jt" <ka**********@gmail.comwrote in message
news:22**********************************@i20g200 0prf.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.....

is there any way to output these characters...???

They're called non-printable for a reason.

What did you expect to see?

--
Bartc

when i execute the same statement in windows a smiley will be
outputted.
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

Sep 5 '08 #9

P: n/a
On September 5, 2008 08:49, in comp.lang.c, Bartc (bc@freeuk.com) wrote:
"jt" <ka**********@gmail.comwrote in message
news:60**********************************@r15g2000 prd.googlegroups.com...
>>

Bartc wrote:
>>"jt" <ka**********@gmail.comwrote in message
news:22**********************************@i20g2000 prf.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 :-) :-)
--
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. ------
Sep 5 '08 #10

P: n/a
"jt" wrote:
>please check the below link..i want to print those symbols..
http://didgood.com/programing/datath...scii-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.
Sep 5 '08 #11

P: n/a
jt <ka**********@gmail.comwrites:
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...???
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>

--
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"
Sep 5 '08 #12

P: n/a
"osmium" <r1********@comcast.netwrites:
[...]
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>

--
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"
Sep 5 '08 #13

P: n/a
Keith Thompson wrote:
"osmium" <r1********@comcast.netwrites:
[...]
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
Sep 5 '08 #14

P: n/a
"Default User" <de***********@yahoo.comwrote:
Keith Thompson wrote:
"osmium" <r1********@comcast.netwrites:
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
Sep 8 '08 #15

This discussion thread is closed

Replies have been disabled for this discussion.