I'm used to holding the left Alt and entering the ASCII character whenever I'm using an unknown keyboard configuration and want to type a special character.

For example, Alt-092 makes a backslash (\).

That's on Windows. Is there a way to do this in Ubuntu ?

Note : I also want to be able to use this in console mode. That means I don't want a solution involving a software with a GUI.

link|improve this question
feedback

3 Answers

up vote 1 down vote accepted

If you are using Gnome (stock Ubuntu does) you can do that by holding down both the Ctrl and Shift keys and typing U followed by the hexadecimal value of the character.

To produce the backslash \, you would hold Ctrl & Shift and type U 5 C

On Windows you type the decimal value while on Linux you type the hexadecimal value (which is usually shorter if you go in the higher numbers). The U stands for Unicode.

A pretty complete table of hexadecimal values can be found here. Warning, page can take a long time to load!

link|improve this answer
The "hexadecimal value" is in fact the Unicode codepoint, unlike "Alt codes" which are ASCII – grawity Oct 7 '10 at 18:33
Wow. Exactly what I needed ! Works everywhere like a charm. Thank you. – Philippe Carriere Oct 12 '10 at 15:08
1  
Now I only need to learn all the codes in hexa.... :( – Philippe Carriere Oct 12 '10 at 15:14
feedback

Linux's console driver doesn't have a facility for entering characters this way... but it isn't really needed since shells can handle this themselves.

$ echo $'\x5c'
\
link|improve this answer
Thats a very nice method.... I can't even find it in the man pages of echo but it works! Is there a way to provide the decimal code instead of the hexidecimal one ? (I learned the decimal codes by heart) – Philippe Carriere Oct 7 '10 at 13:15
Is there a way to use this when I'm in vi or nano ? – Philippe Carriere Oct 7 '10 at 13:17
No, they can only be entered in hex (\xNN) or octal (\NNN). You can use printf if you want to see the hex code for a value. In vim you can type Ctrl-V U and then the 4-digit Unicode codepoint. Also, QUOTING section. – Ignacio Vazquez-Abrams Oct 7 '10 at 14:06
1  
@Silence: (1) Because it's a feature of your shell (usually bash), not of echo. – grawity Oct 7 '10 at 18:33
feedback

Another option (but it does not insert a character by ASCII/Unicode code) is to activate the ComposeKey (like right Alt in my case), so that you can then type things like:

  • Alt = e -> €
  • Alt ' e -> é
  • Alt ^ e -> ê

etc. In case you want to enter frequently used latin letters (as in Spanish, French, etc), this might be faster than having to learn the Unicode code points. It's all about having choice!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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