ASCII characters

J

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...???
 
B

Bartc

jt said:
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?
 
J

jt

Bartc said:
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.
 
C

Chris Dollin

jt said:
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 );
}
 
J

jt

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/datatheory/ascii-0-127.gif
 
L

Lew Pitcher

On September 5, 2008 08:32, in comp.lang.c, jt ([email protected])
wrote:
[snip]
please check the below link..i want to print those symbols..
http://didgood.com/programing/datatheory/ascii-0-127.gif

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. ------
 
L

Lew Pitcher

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. ------
 
L

Lew Pitcher

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. ------
 
B

Bartc

jt said:
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 :) :)
 
L

Lew Pitcher

jt said:
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. ------
 
O

osmium

jt said:
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.
 
K

Keith Thompson

jt said:
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>
 
D

Default User

Keith said:
osmium said:
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
 
R

Richard Bos

Default User said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top