Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-09-2011, 11:11 AM
|
#1
|
Member
Registered: Mar 2005
Posts: 157
Rep:
|
ncurses screen prints garbage
I actually have two reasons for posting this. One is to see if there's an actual name for characters like this:
Hopefully that will show up correctly for you. If not, it's a little box with four numbers in it, one in each corner. I don't know their name or their reason for showing up, so it's hard to look for help.
My main problem, though, is that I wrote a program that prints some output to a console using ncurses as it runs. These characters show up on the console, seemingly at random, and disturb the whole thing. Sometimes I'll also get sets of characters like "[13;" I'm not printing anything bizarre on there, just strings and floating-point numbers. For example, here's some output from a console running now:
Code:
-0.063158 -0.002083 6.009213 0.000000
0.194120 -0.000095[16;1
I don't really know where to go with this because the code is very straightforward (unfortunately I can't post it). Has anyone else had a similar problem? Sorry I can't be more specific, but I don't even know what those things are.
Thanks
|
|
|
02-09-2011, 12:35 PM
|
#2
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
I will speculate that ncurses does not know what type of terminal you are using. The odd-looking character you posted is a printable version of the 'escape', '\x1b', ASCII 27 character. Normally, the terminal will trap sequences of characters that begin with the escape character, and interpret these escape sequences to control the screen and manage cursor and text placement. Evidently, the sequence being sent to the terminal by ncurses is not being trapped by your terminal, and is instead being displayed in the only way it knows how.
What is the value of $TERM, and what kind of terminal/emulator is your application running on?
--- rod.
|
|
|
02-09-2011, 12:56 PM
|
#3
|
Member
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
|
Those are probably UTF-8 characters. Try setting the locale of the terminal you're running in.
Code:
luser@lhost$ env|grep -i utf
LANG=en_US
luser@lhost$ ls -la /usr/share/X11/locale | grep en_US | grep -i utf
drwxr-xr-x 2 root root 4096 Oct 27 2009 en_US.UTF-8
luser@lhost$ export LANG=en_US.UTF-8
luser@lhost$ env|grep -i utf
LANG=en_US.UTF-8
|
|
|
02-09-2011, 02:06 PM
|
#4
|
Member
Registered: Mar 2005
Posts: 157
Original Poster
Rep:
|
Thanks for the responses. Here is the information you requested. Note that the locale is already set to en_US.UTF-8, and that I'm using gnome-terminal.
Code:
$ echo $TERM
xterm
$ env|grep -i utf
LANG=en_US.utf8
GDM_LANG=en_US.utf8
$ ls -la /usr/share/X11/locale | grep en_US | grep -i utf
drwxr-xr-x. 2 root root 4096 Oct 22 13:32 en_US.UTF-8
I'm not sure I know how an escape character would get into the values I'm printing. They're all just floating-point numbers. Also, here's something even weirder. The box is sometimes partially overwritten by a [SOME_NUMBER; such that the [ is on top of half of the box. I can even select it individually with the mouse. See the attached sequence of screenshots.
Other thoughts?
Thanks!
|
|
|
02-09-2011, 02:17 PM
|
#5
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
Quote:
Originally Posted by MALDATA
I'm not sure I know how an escape character would get into the values I'm printing.
|
If you are using ncurses to print them, then they are getting there because that's how ncurses tells the terminal where and with what attribute(s) to display the text.
What happens if you use a different terminal type, such as an xterm?
--- rod.
|
|
|
02-09-2011, 02:39 PM
|
#6
|
Member
Registered: Mar 2005
Posts: 157
Original Poster
Rep:
|
xterm seems to display everything correctly. I don't get any of these anomalies. Do you happen to know why that might be the case? That is, what is gnome-terminal doing differently from xterm?
Thanks!
|
|
|
02-09-2011, 03:10 PM
|
#7
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
It isn't correctly emulating an xterm. It's hard to say whether that is a bug, or whether it simply wasn't intended to do so. Perhaps it is the setting of $TERM that is incorrect. I've never really figured out which is the chicken and which is the egg. I don't have gnome terminal; have you checked to see whether it has a configurable emulation? Maybe it can be set to xterm emulation.
--- rod.
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 11:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|