Re: Why does my program change the characters in my shell

From: Andrew Falanga (excalibur_at_icehouse.net)
Date: 06/28/03


Date: Fri, 27 Jun 2003 18:17:34 -0600

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! =-----



Relevant Pages

  • Re: Why does my program change the characters in my shell
    ... resulting in bytes beyond the end of the string being printed. ... terminal to a graphics character set. ... That does a terminal reset, sends the TERMINFO init string for ...
    (comp.unix.programmer)
  • Re: OS X Terminal.app and Aptitude
    ... a hunch that your locale on Debian is set to a UTF-8 flavor and that aptitude ... is emitting line-drawing in UTF-8, but that Terminal isn't doing the Right ... hmm - but the line-drawing characters were all double-width when drawn ... strings that are in the terminfo. ...
    (Debian-User)
  • Re: [PATCH] console UTF-8 fixes
    ... enough to edit random text files with a random editor without problems. ... all characters equally (a good hint would be if the terminal doesn't even ... support wide characters). ... The terminfo database exists for a good reason ...
    (Linux-Kernel)
  • Re: [PATCH] console UTF-8 fixes
    ... enough to edit random text files with a random editor without problems. ... all characters equally (a good hint would be if the terminal doesn't even ... don't think terminfo has anything to do with it. ... the kernel knows to jump 2 character cells on them? ...
    (Linux-Kernel)
  • Re: parse acs termcap entry
    ... >> not exactly (see the terminfo manpage). ... > it outputs the entire ac string. ... The ac= string is a list of character pairs. ... In termcap form, the text is just that: ...
    (comp.unix.programmer)