# Setting Locale - Accented Characters in Console



## Hunter8896 (Jul 30, 2019)

Since moving to FreeBSD, I have not be able to get accented characters (such as é, or ç, or è etc.) to display properly in the terminal. I know the problem is my locale not being set properly, but I can not get it to change for some reason. I have read all of chapter 22.2 and followed the instructions there. My current ~/.login_conf looks like this:

```
me:\
    :charset=UTF-8:\
    :lang=en_US.UTF-8:
```
but after logging out and logging back in or restarting, the output of `locale` is always:

```
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
```
Does anyone know how to make these changes to ~/.login_conf take effect ? I haven't tried editing /etc/login.conf, but I shouldn't have to anyway.


----------



## SirDice (Jul 30, 2019)

See login.conf(5):

```
The default /etc/login.conf shipped with FreeBSD is an out of the box
     configuration.  Whenever changes to this, or the user's ~/.login_conf,
     file are made, the modifications will not be picked up until cap_mkdb(1)
     is used to compile the file into a database.  This database file will
     have a .db extension and is accessed through cgetent(3).  See getcap(3)
     for a more in-depth description of the format of a capability database.
```

It's typically easier to set the LANG environment variable in startup scripts (~/.cshrc for example for C Shells).

C Shells:

```
setenv LANG en_US.UTF-8
```
Bourne Shells:

```
export LANG=en_US.UTF-8
```


----------



## Hunter8896 (Jul 31, 2019)

I tried applying `cap_mkdb` to ~/.login_conf, but that that didn't change the locale settings either. Manually setting the environment variables in my ~/.cshrc did do the trick however so thank you for that suggestion! I am still puzzled as to why the .login_conf method doesn't seem to work though


----------



## chrbr (Jul 31, 2019)

I would not wonder if you just have to replace `me` in the configuration file by your user name. That worked for me with /etc/login.conf. And yes, running `cap_mkdb` has been necessary.


----------



## Hunter8896 (Aug 2, 2019)

I switched `me` to my username, but this didn't set the locale information on login either. I wonder if an essential step is perhaps missing from the handbook or there is a bug in the current release ?


----------



## SirDice (Aug 2, 2019)

Wozzeck.Live said:


> it will generate an encrypted version of the database login.conf.db


As far as I know it's not encrypted. A database usually scales better than a plain text file (with thousands of definitions and classes).


----------



## DavidMarec (Aug 3, 2019)

Hunter8896 said:


> Does anyone know how to make these changes to ~/.login_conf take effect ? I haven't tried editing /etc/login.conf, but I shouldn't have to anyway.



I just add a user to check this out:


```
david:~>su - ger
Password:
Need to quickly return to your home directory? Type "cd".
        -- Dru <genesis@istar.ca>
ger@llanura:~ % locale
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
ger@llanura:~ % vim .login_conf
ger@llanura:~ % logout
david:~>su - ger
Password:
Time to change your password? Type "passwd" and follow the prompts.
        -- Dru <genesis@istar.ca>
ger@llanura:~ % locale
LANG=de_DE.ISO8859-1
LC_CTYPE="de_DE.ISO8859-1"
LC_COLLATE="de_DE.ISO8859-1"
LC_TIME="de_DE.ISO8859-1"
LC_NUMERIC="de_DE.ISO8859-1"
LC_MONETARY="de_DE.ISO8859-1"
LC_MESSAGES="de_DE.ISO8859-1"
LC_ALL=
ger@llanura:~ % pw usershow ger
ger:*:9420:0::0:0:ger:/home/ger:/bin/tcsh
ger@llanura:~ % cat .login_conf
# $FreeBSD: stable/12/share/skel/dot.login_conf 77995 2001-06-10 17:08:53Z ache $
#
# see login.conf(5)
#
me:\
    :charset=iso-8859-1:\
    :lang=de_DE.ISO8859-1:
```

At the time I opened .login_conf (with vim), I did only uncomment the default me: fields.
So, it sounds that there is no need to use cap_mkdb on this local file, but I know this is really necessary onto /etc/login.conf.


----------



## DewayneG (Mar 22, 2021)

I've spent a little time on this today because I wanted to eliminate the duplication that I have with /etc/cshr.cshrc and /etc/login.conf.  As I found myself here, ... .  This is my goal (I'm in Australia, so):

```
LANG=en_AU.UTF-8
LC_CTYPE=C
LC_COLLATE=C
LC_TIME="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_ALL=
```
which is achieved with the following changes to the default: in /etc/login.conf and performing `cap_mkdb /etc/login.conf`

```
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,[HIGHLIGHT]LC_COLLATE=C,LC_CTYPE=C[/HIGHLIGHT]:\
:charset=UTF-8:\
:lang=en_AU.UTF-8:\
```

The testing for this being successful was to create various users with both the default and non-default classes and identical outcomes in interactive and "batch" processes. (using `su -c $CLASS $ValidUser -c "env; locale"`)

Its important *not* to include LC_ALL in the setenv, as in

```
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,[HIGHLIGHT]LC_ALL=en_AU.UTF-8[/HIGHLIGHT],LC_COLLATE=C,LC_CTYPE=C:\
```
otherwise your locale information becomes:

```
LANG=en_AU.UTF-8
LC_CTYPE="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_ALL=en_AU.UTF-8
```

*BSD basics never seems to become old.  I hope that my first post is readable and saves you some time.


----------

