LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   terminal and konsole windows show strange characters (https://www.linuxquestions.org/questions/linux-software-2/terminal-and-konsole-windows-show-strange-characters-759057/)

SaintDanBert 10-01-2009 03:29 PM

terminal and konsole windows show strange characters
 
When I open a terminal or konsole window, output (either STDOUT or STDERR) sometimes contains funny characters instead of something meaningful. Can someone explain how I might correct this situation?

ANALYSIS:
One very repeatable example involves using the manual page command
Code:

man set

... man page output ...

upstart - event-based init daemon

In my copy of the output, there are several problems in the very first screen. In the synopsis section, there is "{ value | ?value? ..."
Replace the '?' with a lower-case-a-under-a-carat character (a-hat).
I suspect the garble character might be apostrophe in real life.

In other places, I see var?/able or how?/ever or trans?/action where
the '?' is again a-hat and the '/' represents end of line or newline.
I suspect the garble character might be a hyphen in real life.

All of this suggests that there is a conflict between the character stream written to STDOUT by the man command and the character-display settings (is that "code page" or similar?) of the specific terminal or konsole in use.

In specific, I use konsole v1.6.6 from KDE v3.5.10. In general, I'm
running Ubuntu Hardy (v8.04.3 LTS).

Thanks,
~~~ 0;-Dan

epilitimus 10-01-2009 10:01 PM

Is this a recent problem? Does it happen from the kernel console? Does the keyboard render the correct characters? Does it happen everytime, or just occasionally?

You can use xmodmap to see the current translation tables. Another possibility is that your terminal program is not properly interpreting the console control codes.

SaintDanBert 10-02-2009 12:49 PM

here is more detail
 
A getty console ( ctrl-alt-Fn ) shows the apostrophe and hypen instead of the a-hat.

When I run xmodmap here are the results:
Code:

user@host:~$ xmodmap
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift      Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control    Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Alt_R (0x71),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3
mod4        Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x7c)

This does not shed any light on the a-hat garble -- at least not for me.

I also get the following: (edited for readability)
Code:

user@host:~$ stty --all

speed 38400 baud; rows 40; columns 90; line = 0;

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts

-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff -iuclc -ixany -imaxbel -iutf8

opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0

isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

On the getty-console, xmodmap does not apply but I get the following details:
Code:

user@host:~$ stty --all

speed 38400 baud; rows 48; columns 128; line = 0;

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel -iutf8

opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

I will need to sift through to explain the differences. (blush) It has been a lot of years since I played termcap/terminfo games.

~~~ 0;-Dan

epilitimus 10-02-2009 04:56 PM

The reason for checking the getty console was to see if it was a problem above or below the kernel/X boundary. Since it works fine from a kernel level console the problem has to be X or above.

The keycode translation tables for X can be viewed with "xmodmap -pk" check where the apostrophe and hyphen are listed. On my machine they are at 48 and 20 (as "minus") respectively. They may be different on you machine. Since X reads the keyboard in raw mode and does it's own translations the termcap/getty settings aren't really important.

Also on a Konsole window you can set the character encoding under the Settings/Encoding menu. Try the various options and see if that fixes it.

SaintDanBert 10-02-2009 05:18 PM

Quote:

Originally Posted by epilitimus (Post 3705517)

The keycode translation tables for X can be viewed with "xmodmap -pk" check where the apostrophe and hyphen are listed. On my machine they are at 48 and 20 (as "minus") respectively. They may be different on you machine. Since X reads the keyboard in raw mode and does it's own translations the termcap/getty settings aren't really important.

What I get from xmodmap -pk is:
Code:

    20            0x002d (minus)                0x005f (underscore)       

    48            0x0027 (apostrophe)        0x0022 (quotedbl)

This feels very much like a "smart quotes" problem in some word processing software. In that situation, one sees the opening double-quote with a top-dot and left curl. Later one sees the closing double-quote with a right curl and bottom-dot. The data on file is different from whatever one sees on screen or print and filter software sees junk instead of "double-quote".

I will play with the menu-options values within konsole and see what happens. Now where is my VT100 escape code manual...

when I looked at Menu->Settings->Encoding
Code:

Western European 8859-1
I have the option to select Default whatever that might be.

I have the option to select various UTF xxxx options. I tried UTF8 and the a-hat problem resolved.

QUESTION: Does this tell me that
Code:

man something  # implies man | less
generates UTF8 output? How would I know? How am I supposed to know which other programs expect some other output format?

QUESTION: How do I set this and make it sticky for any use of 'konsole'? of other 'terminal' or 'x-term'?

Thanks, again,
~~~ 0;-Dan
~~~ 8d;-Dan

epilitimus 10-02-2009 05:46 PM

I just leave the encoding on mine set to "default", I suppose I could plow through documentation to see where it detirmines what the "default" encoding is...does X have a default encoding in the confguration file, hmmm, not sure...but it works so why bother;)

man et. al. are console based programs so I believe they are going to use the "TERM" environment variable to figure out how to do any formatting/special characters. My system has the TERM variable set to "xterm", not really sure what the other options are...again it works as is so why beat my head against that particular wall as well.


All times are GMT -5. The time now is 05:41 AM.