LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   utf8 cyrillic text in console emacs (https://www.linuxquestions.org/questions/slackware-14/utf8-cyrillic-text-in-console-emacs-665192/)

tramni1980 08-25-2008 04:19 AM

utf8 cyrillic text in console emacs
 
Hello!
I am running Slackware 12.1.
I want to use emacs without X, i.e. in the console only and write utf8 encoded cyrillic text. Is there a way to achieve that?
In the Changes and Hints file there was something about enabling utf8 console, probably that is what I should do, but Patrick warns that there is some danger of misinterpretation of some commands. So can I achieve my goal without running into this risk? I wish I could leave everything in english on my machine, I just want to write utf8 cyrillic text by means of console emacs.

Regards,
Martin

ErV 08-25-2008 05:15 AM

console can be switched into unicode mode by running unicode_start.
This can be done inside /etc/rc.d/rc.font.
This will break midnight commander (patched version "mc-4.6.1_utf8-i486-1pin.tgz" is available somewhere).
if your kernel is 2.6.24 or higher, then console is in unicode mode by default.

tramni1980 08-25-2008 05:36 AM

Quote:

Originally Posted by ErV (Post 3258807)
console can be switched into unicode mode by running unicode_start.
This can be done inside /etc/rc.d/rc.font.
if your kernel is 2.6.24 or higher, then console is in unicode mode by default.

My kernel is 2.6.24.5-smp. I ran the script unicode_start and tried to open a utf8 text file. I switched the language environment to Bulgarian. And still all that was displayed in the console was:
????????????????????????????????????????????
????????????????????????????
and so on. Besides, how do I switch in the console from cyrillic to latin keyboard layout?

ErV 08-25-2008 08:11 AM

Quote:

Originally Posted by tramni1980 (Post 3258823)
My kernel is 2.6.24.5-smp. I ran the script unicode_start and tried to open a utf8 text file. I switched the language environment to Bulgarian. And still all that was displayed in the console was:
????????????????????????????????????????????
????????????????????????????

Have you configured console font? If it doesn't have bulgarian characters, you won't see them.
Take a look at this thread and make sure you set system locale and console font correctly.

Quote:

Originally Posted by tramni1980 (Post 3258823)
Besides, how do I switch in the console from cyrillic to latin keyboard layout?

With right control key (on my machine, at least). That's of course if you configured console keyboard correctly.
--EDIT--
Basically, to make any console program to display any characters you must make sure, that:
1) terminal is set to correct encoding
2) terminal font has characters you need and correct character map is selected.
3) program communicates with terminal in same encoding terminal is set to. I.e. if terminal will be cp855 and program will communicate with it as if it was utf8 this won't make any good.

I don't know how to #3 in emacs. Normally setting system locale to the one used by terminal should be enough.

It doesn't really matter wheter it is unicode or not.

tramni1980 08-25-2008 11:03 AM

Ok, thank you very much I will try these.
I have just something else to ask before I switch to tweaking.
1. I want to minimize the risk of some commands being misinterpreted due to the bg_BG.utf8 locale I am going to set. So what environment variables shall I export? All I want is just being able to type cyrillic in emacs. Nothing more.
Is it:
Code:

export LANG=bg_BG.utf8
export LC_MESSAGES=en_US

2. Which font shall I set:
Will this:
Code:

setfont -v koi8c-8x16 -u koi8r
do for utf8 Bulgarian? Bulgarian does not have letters that are not present in Russian.

3. I found I have:
/usr/share/kbd/keymaps/i386/qwerty/bg_bds-utf8.map.gz
so I will do:

Code:

if [ -x /usr/bin/loadkeys ]; then
 /usr/bin/loadkeys ru-ms.map
fi

4. For my purpose, do I have to add:
Code:

Option        "XKbLayout" "us,ru(winkeys)"
to the other necessary lines in the Device Section of xorg.conf?
Are these extra lines in xorg.conf that configure the console keyboard?

Thank you for your attention.

Regards,
Martin

tramni1980 08-25-2008 11:10 AM

Sorry for cross-posting, but I made a mistake with the 3rd point:

it should be:

3. I found I have:
/usr/share/kbd/keymaps/i386/qwerty/bg_bds-utf8.map.gz
so I will do:

Code:

if [ -x /usr/bin/loadkeys ]; then
 /usr/bin/loadkeys bg_bds-utf8.map
fi

Is there anything else to do in addition to these 4 steps?

Uncle_Theodore 08-25-2008 11:10 AM

xorg.conf doesn't really have anything to do with console. Though, usually, to be able to switch between Latin and Cyrillics in X programs, you do something like this in your xorg.conf

Option "XkbLayout" "us,ru(winkeys)"
Option "XkbOptions" "grp:ctrl_shift_toggle,grp_led:scroll"

ErV 08-25-2008 12:07 PM

Quote:

Originally Posted by tramni1980 (Post 3259107)
2. Which font shall I set:
Will this:
Code:

setfont -v koi8c-8x16 -u koi8r
do for utf8 Bulgarian? Bulgarian does not have letters that are not present in Russian.

Don't know. You should seek stanard encoding for your language (I really don't think it is koi8-r), anyway. I've been configuring all this stuff more than year ago, and I don't remember a lot of details.
Take a look at "man setfont". From what i remember it has a lot of details about how exactly terminal works, where are available fonts, keyboard maps and unicode maps (the ones given with setfont's "-u" option) stored.
There should be more manpages about subject, but I don't remember their exact names (you should be able to find them by setfont's manpage references)
According "man setfont" there are following important directories:
/usr/share/kbd/unimaps
/usr/share/kbd/consolefonts
/usr/share/kbd/consoletrans
"consolefonts" directory have several readme's, so take a look at them.
reading "man loadkeys" and "man unicode_start" also might provide several insights.

Quote:

Originally Posted by tramni1980 (Post 3259107)
3. I found I have:
/usr/share/kbd/keymaps/i386/qwerty/bg_bds-utf8.map.gz
so I will do:

Code:

if [ -x /usr/bin/loadkeys ]; then
 /usr/bin/loadkeys ru-ms.map
fi


"loadkeys ru-ms" will load russian keyboard layout. I don't know if it is identical to bulgarian keyboard or not.

Quote:

Originally Posted by tramni1980 (Post 3259107)
4. For my purpose, do I have to add:
Code:

Option        "XKbLayout" "us,ru(winkeys)"

No.

I'd like to provide more info, but, unfortunately, right now I'm using broken monitor which refuses to display anything except 1024x768x85 hz screen mode (so I don't see "normal" terminals at all), so I won't be able to play around with terminal settings and probably won't be able to provide further assistance.


All times are GMT -5. The time now is 02:18 PM.