Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After running programs that output unrecognizable code, the whole shell would be full of unrecognizable code.

alt text

How can I correct this?

share|improve this question
    
Looks like it changed the characters set/encoding of the shell. Not sure how to set it back though. –  Matthew Lock Nov 11 '09 at 2:44
add comment

2 Answers

up vote 6 down vote accepted

SI/SO VT100 Control Characters

The garbled characters are likely due to the terminal getting a SI character (Shift In; ASCII 14; Control-N). SI is a VT100 control character that can cause the terminal to switch to an alternate character set. Many real terminals (e.g. an actual hardware device, or just the text-only console of an OS) and terminal programs honor this escape code.

The direct way to switch back to the normal character set is to send a SO character (Shift Out; ASCII 15; Control-O) to the terminal.

Recovery

Because the character set is switched, you may have to type the recovery commands “blind” (without relying on seeing what you have typed).

Usually the echo command will be useful. Often you can type
E C H O Space Control-V Control-O Enter / Return
to get the terminal to see a Control-O (the Control-V tells the input-side of the terminal that the next is to be passed literally, otherwise the input side will ‘eat’ the character before it gets the the shell and thus before it can be sent back to the output side of the terminal).

If you can assume a reasonable shell with a printf builtin (or no shell builtin and a reasonable external printf command), you can use printf '\017' to send a Control-O to the terminal.

share|improve this answer
    
It works exactly.thanks a lot. –  Jichao Nov 12 '09 at 13:15
    
If anyone ever runs into this problem on a terminal that is not derived from a VT100, an alternative to the VT100-specific control sequence generated via echo or printf is tput rmacs (as pointed out in another answer by Ignacio Vazquez-Abrams). –  Chris Johnsen Oct 10 '10 at 3:35
    
the answer is correct but by having the E C H O shown as caps I'm afraid you might mislead someone into typing them in caps ... which would fail. –  CarlF Jun 17 '11 at 16:15
add comment

Did you try the unix reset command?

This is usually the result of dumping a binary file (a program, or a data file) to the terminal (cat some.mp3 or similar). Usually typing reset will get your terminal back in order. If that doesn't work, the next thing to try is a reset function on your terminal application -- look for it in the application's menus. (PuTTY, for example, has a Reset Terminal in its system menu.)

Rarely, neither of these work, and you'll just have to shut down that terminal or shell and start another one.

share|improve this answer
    
thanks,it works too. –  Jichao Nov 12 '09 at 13:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.