f



Why does my program change the characters in my shell

Hello,

I'd like to know what the typical reason for this is.  I'm debugging a
program I've written, and to make sure I'm using sscanf( ) and strcpy(
).  However, when it gets done puting the data on stdout, the program is
supposed to prompt me for action.

What is displayed is really weird text.  No English alphabetic
characters, just right angled shapes and stuff.  What normally alters
the character set of stdout (don't know if I worded that correctly)?

Andy



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
0
Andrew
6/26/2003 3:06:23 AM
comp.unix.programmer 10848 articles. 0 followers. kokososo56 (350) is leader. Post Follow

6 Replies
879 Views

Similar Articles

[PageSpeed] 19

Hi Andy,
  I hope you must be ending each string with NULL characters otherwise
you will face this problem.
  It will be better if you just give part of the code and output.

Anand
"Andrew Falanga" <excalibur@icehouse.net> wrote in message
news:3EFA632F.2FC168CD@icehouse.net...
> Hello,
>
> I'd like to know what the typical reason for this is.  I'm debugging a
> program I've written, and to make sure I'm using sscanf( ) and strcpy(
> ).  However, when it gets done puting the data on stdout, the program is
> supposed to prompt me for action.
>
> What is displayed is really weird text.  No English alphabetic
> characters, just right angled shapes and stuff.  What normally alters
> the character set of stdout (don't know if I worded that correctly)?
>
> Andy
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


0
Anand
6/26/2003 4:42:08 AM
Andrew Falanga wrote:
> Hello,
> 
> I'd like to know what the typical reason for this is.  I'm debugging a
> program I've written, and to make sure I'm using sscanf( ) and strcpy(
> ).  However, when it gets done puting the data on stdout, the program is
> supposed to prompt me for action.
> 
> What is displayed is really weird text.  No English alphabetic
> characters, just right angled shapes and stuff.  What normally alters
> the character set of stdout (don't know if I worded that correctly)?

Your terminal is confused or switched into character-graphics mode...
try "reset" command
You can trace your program with "strace"

0
Lorinczy
6/26/2003 4:46:02 AM
Andrew Falanga wrote:
[...]
> What is displayed is really weird text.  No English alphabetic
> characters, just right angled shapes and stuff.  What normally alters
> the character set of stdout (don't know if I worded that correctly)?

That's the alternate charset used for example to display frames
in a VT100 like terminal.

Issue

tput smacs
tput rmacs

to set/reset the alternet charset. (rmacs == reset mode alternet
charset)

-- 
St�phane
0
Stephane
6/26/2003 10:44:27 AM
Lorinczy Zsigmond <nospam@for.me> wrote in message news:<3EFA7A8A.2060406@for.me>...
> Andrew Falanga wrote:
> > Hello,
> > 
> > I'd like to know what the typical reason for this is.  I'm debugging a
> > program I've written, and to make sure I'm using sscanf( ) and strcpy(
> > ).  However, when it gets done puting the data on stdout, the program is
> > supposed to prompt me for action.
> > 
> > What is displayed is really weird text.  No English alphabetic
> > characters, just right angled shapes and stuff.  What normally alters
> > the character set of stdout (don't know if I worded that correctly)?
> 
> Your terminal is confused or switched into character-graphics mode...
> try "reset" command
> You can trace your program with "strace"

alternatively, you can play a fun game instead; cat /bin/ls and try
and ^C it before its finished cat'ing. sometimes if you're lucky, the
characters will be ok again.
0
noogie
6/27/2003 12:11:17 PM
noogie@cyberspace.org (Alex Sisson) wrote:
>Lorinczy Zsigmond <nospam@for.me> wrote:
>> Andrew Falanga wrote:
>> > Hello,
>> > 
>> > I'd like to know what the typical reason for this is.  I'm debugging a
>> > program I've written, and to make sure I'm using sscanf( ) and strcpy(
>> > ).  However, when it gets done puting the data on stdout, the program is
>> > supposed to prompt me for action.

That is probably the result of leaving a string unterminated,
resulting in bytes beyond the end of the string being printed.
One of those bytes happened to be ^N, which switches the
terminal to a graphics character set.  That is a common result
of displaying binary data to a terminal.  There are other weird
attribute combinations that can occasionally happen, but that
one is the most common.

>> > What is displayed is really weird text.  No English alphabetic
>> > characters, just right angled shapes and stuff.  What normally alters
>> > the character set of stdout (don't know if I worded that correctly)?
>> 
>> Your terminal is confused or switched into character-graphics mode...
>> try "reset" command
>> You can trace your program with "strace"
>
>alternatively, you can play a fun game instead; cat /bin/ls and try
>and ^C it before its finished cat'ing. sometimes if you're lucky, the
>characters will be ok again.

That's even more hit or miss than the _reset_ command, which
doesn't always clear some of the stranger states a terminal can
be put into.  But there are ways to handle it...

  alias sane='echo -e "\\033c";tput is2;stty $(stty -g)'

That does a terminal reset, sends the TERMINFO init string for
your terminal, and then resets all of the parameters to whatever
they were at the time this alias was defined (presumably it is
in an rc file run when the terminal session was invoked, so it
will be correct).

A demonstration of the difference is easy.

    echo -e "\016"

will cause the line drawing characters to be used, and either
the _reset_ command or the above _sane_ alias will restore the
expected character font.  But

    echo -e "\033[?25l"

will cause the cursor to disappear, and _reset_ will not restore
it.  But _sane_ will.

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com
0
Floyd
6/27/2003 10:51:09 PM
Floyd Davidson wrote:

> noogie@cyberspace.org (Alex Sisson) wrote:
> >Lorinczy Zsigmond <nospam@for.me> wrote:
> >> Andrew Falanga wrote:
> >> > Hello,
> >> >
> >> > I'd like to know what the typical reason for this is.  I'm debugging a
> >> > program I've written, and to make sure I'm using sscanf( ) and strcpy(
> >> > ).  However, when it gets done puting the data on stdout, the program is
> >> > supposed to prompt me for action.
>
> That is probably the result of leaving a string unterminated,
> resulting in bytes beyond the end of the string being printed.
> One of those bytes happened to be ^N, which switches the
> terminal to a graphics character set.  That is a common result
> of displaying binary data to a terminal.  There are other weird
> attribute combinations that can occasionally happen, but that
> one is the most common.
>
> >> > What is displayed is really weird text.  No English alphabetic
> >> > characters, just right angled shapes and stuff.  What normally alters
> >> > the character set of stdout (don't know if I worded that correctly)?
> >>
> >> Your terminal is confused or switched into character-graphics mode...
> >> try "reset" command
> >> You can trace your program with "strace"
> >
> >alternatively, you can play a fun game instead; cat /bin/ls and try
> >and ^C it before its finished cat'ing. sometimes if you're lucky, the
> >characters will be ok again.
>
> That's even more hit or miss than the _reset_ command, which
> doesn't always clear some of the stranger states a terminal can
> be put into.  But there are ways to handle it...
>
>   alias sane='echo -e "\\033c";tput is2;stty $(stty -g)'
>
> That does a terminal reset, sends the TERMINFO init string for
> your terminal, and then resets all of the parameters to whatever
> they were at the time this alias was defined (presumably it is
> in an rc file run when the terminal session was invoked, so it
> will be correct).
>
> A demonstration of the difference is easy.
>
>     echo -e "\016"
>
> will cause the line drawing characters to be used, and either
> the _reset_ command or the above _sane_ alias will restore the
> expected character font.  But
>
>     echo -e "\033[?25l"
>
> will cause the cursor to disappear, and _reset_ will not restore
> it.  But _sane_ will.
>
> --
> Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
> Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com

Thank you much, Floyd, for this explaination.  I actually suspected it was
something like my program trying to print characters beyond the defined boundries
of my strings.

Also, thanks much for the alias listed above.  I wonder, does it need to be
modified any to work on Sun Solaris?  Also, I thank you because the reset command
didn't reset the terminal.

Thank you all, I really like this group.
Andy




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
0
Andrew
6/28/2003 12:17:34 AM
Reply: