LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to insert Unicode (or extended ASCII) characters in text files? (https://www.linuxquestions.org/questions/linux-general-1/how-to-insert-unicode-or-extended-ascii-characters-in-text-files-936003/)

tommyttt 03-23-2012 03:16 AM

How to insert Unicode (or extended ASCII) characters in text files?
 
Not sure if this question should go here or under software so I put it here. Moderator can move if desired.

I know that word processors have facilities for inserting special characters (Unicode) into documents. What I want to do is have something similar using a plain text editor like Kate or Gedit. I've tried goint the compose key route but that seems to be rather limited as to what characters can be generated.

So far I've been using cut & paste from charts but that is a PITA. Things like symbols for currency, mathematics, engineering, etc.

For example (cut & pasted) € Œ ™ ¢ § » © ÷ µ.

Thanks, Tom

eSelix 03-23-2012 06:25 AM

It is depended on keyboard layout rather than editor. And compose key is one of solutions, I don't think it is limited. For example € is created by "E" followed by "=", © by "o" followed by "c", Œ is "O" and "E", § is "o" and "s", etc. For list of possible combinations look at your /usr/share/X11/locale/en_US.UTF-8/Compose and other locales if you have. You can also configure your own combinations (look at "man Compose"), but I do not tested this.

The other methods are configure your own keyboard layout, but if you want to use many non standard characters you can stuck at too low buttons on your keyboard. But other hand you can define many layouts and easily switch between them.

Geriao 04-02-2012 08:23 PM

Also, if you know the hex code for the character you want to insert, simply go to your editor and press "CTRL + SHIFT + U". A small underlined "u" will appear, and then insert the hex code (in lower case) and then enter. For example, Ñ is "d1", ¢ is "a2", etc.

DavidMcCann 04-03-2012 12:50 PM

If you copy the compose file to ~/.XCompose, you can edit it and add anything you need. In fact, all the symbols you've listed are there: http://www.hermit.org/Linux/ComposeKeys.html
I've added things like ≥, ≠, and ∅.

For things where you can't think of a combination, you can use the AltGr key. Just add the extras to your /usr/share/X11/xkb/symbols/us file:
key <AE04> {[4, dollar, sterling]};
will give £ from AltGr+4 instead of using Compose L-.

KurtBleach 12-28-2012 05:28 PM

Big thanks to Geriao.
I have searched far and wide for the answer on this issue.
So simple to do, it is brilliant.

Hey, I don't know how "relevant and timely" I might be here :), but I haven't posted in some time and this here bump could help other people looking for a genius solution for posting with ASCII.


All times are GMT -5. The time now is 03:14 PM.