ProgrammingThis 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.
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.
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:
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.
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?
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.
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.
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?
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.