accented characters on shell

Davide Pala

New Member

Reaction score: 2
Messages: 7

Hi all, I'm new in the FreeBSD world, I've got a question: how I can set up my keyboard for the accented characters? I've used the standard IT keyboard layout but when use the "è" key the character printed on the shell is /350 instead of "è".

Can anyone help me? Thanks.
 

Carpetsmoker

Daemon

Reaction score: 188
Messages: 1,012

I've used the standard IT keyboard layout but when use the "è" key the character printed on the shell is /350 instead of "è".

Then you don't use a standard (US or US-intl) keyboard, since a standard keyboard doesn't have an è key :)

In any case, setting the locale to UTF-8 is usually enough to solve the problem; this can be done with by setting the environment variable LC_ALL (with setenv or export, depending on your shell) to en_US.UTF-8 in your shell startup file.
 
OP
Davide Pala

Davide Pala

New Member

Reaction score: 2
Messages: 7

Thank you Carpetsmoker. I've set LC_ALL in my /etc/login.conf file. Now this is the output of locale -a command:

Code:
LANG=it_IT.UTF-8
LC_CTYPE="it_IT.UTF-8"
LC_COLLATE="it_IT.UTF-8"
LC_TIME="it_IT.UTF-8"
LC_NUMERIC="it_IT.UTF-8"
LC_MONETARY="it_IT.UTF-8"
LC_MESSAGES="it_IT.UTF-8"
LC_ALL=

The situation is the same, when I press "è" key I've /350 on the console.
 

Juanitou

Well-Known Member

Reaction score: 127
Messages: 453

I never modify /etc/login.conf, I use ~/.login_conf, for example:
Code:
me:\
 :charset=ISO8859-1:\  # or iso-8859-1
 :lang=fr_FR.ISO8859-1:
 
OP
Davide Pala

Davide Pala

New Member

Reaction score: 2
Messages: 7

Juanitou if I understand correctly the file you specify is valid for a single user, I want to make the change valid for all users (existing and new)
 

Juanitou

Well-Known Member

Reaction score: 127
Messages: 453

That’s what I also understand, but never tried it. Have you followed the instructions on top of /etc/login.conf to rebuild the database? # cap_mkdb /etc/login.conf
 

Juanitou

Well-Known Member

Reaction score: 127
Messages: 453

I have also found this old comment in my notes, not sure what is worth: UTF-8 (default for root as defined in login.conf) does not work to type special chars.
 

kpa

Beastie's Twin

Reaction score: 1,842
Messages: 6,318

The default console in FreeBSD known as the sc(4) console has rather poor support for both 8-bit character sets and Unicode (doesn't support at all in fact). The newer vt(4) console should support Unicode when used with a UTF-8 locale but you need to first figure out if the font used actually has the needed characters or if you have to load a special font that has those characters.

More information here:

https://wiki.freebsd.org/Newcons
 

Juanitou

Well-Known Member

Reaction score: 127
Messages: 453

I have also found this old comment in my notes, not sure what is worth: UTF-8 (default for root as defined in login.conf) does not work to type special chars.
I can confirm it. These two lines added to the default:\ section of /etc/login.conf do not allow typing special characters, it even blocks the keyboard for some seconds:
Code:
:charset=UTF-8:\
:lang=it_IT.UTF-8:
While these work:
Code:
:charset=ISO8859-1:\
:lang=it_IT.ISO8859-1:
 

chrbr

Aspiring Daemon

Reaction score: 351
Messages: 866

Dear Davide Pala,
things regarding localization are rather confusing. Now I use
Code:
  :charset=UTF-8:\
  :lang=de_DE.UTF-8:\
in my /etc/login.conf because of the Umlaute. If you do not use UTF-8 you might face problems in communication with the outer world using text based programs as mail/mutt or news/slrn in case mails or messages are UTF-8 encoded.

Therefore I recommend to test the UTF-8 configuration with the software you intent to use. If this is not acceptable it is possible to fake an environment by using x11/luit. But I think this rather a workarround if there is any other option.
 

patpro

Active Member

Reaction score: 16
Messages: 238

I can confirm it. These two lines added to the default:\ section of /etc/login.conf do not allow typing special characters, it even blocks the keyboard for some seconds:

That's strange. I run FreeBSD 9.3-RELEASE, and I use quite similar lines in ~/.login_conf. It's working great:

Code:
$ grep -v ^# ~/.login_conf 
me:\
    :charset=UTF-8:\
    :lang=en_US.UTF-8:

But I'm not using console directly, I've made this setting to use extended ASCII characters through ssh connection. My terminal emulator (Apple's Terminal.app) is configured to use UTF-8 by default too.
 
OP
Davide Pala

Davide Pala

New Member

Reaction score: 2
Messages: 7

I solved it by specifying the font in the /etc/rc.conf file, these are the lines I have added:
Code:
font8x16="iso15-8x16.fnt"
font8x14="iso15-8x14.fnt"
font8x8="iso15-8x8.fnt"
and in the login.conf file I've used the it_IT.iso8859-15 locale.
 
Top