# Switch locale to UTF8 help



## stratacast1 (Jun 13, 2018)

I've been hunting all over to find a solution for this, but the things I've tried haven't worked. I edited the /etc/login.conf file and added the

```
:charset=UTF-8:\
        :lang=en_US.UTF-8:
```
lines to the file and ran `cap_mkdb /etc/login.conf`, but no luck. I've also done the same thing to my users ~/.login_conf file, and also no luck. My local is still stuck at

```
LANG=en_US.US-ASCII
LC_CTYPE="en_US.US-ASCII"
LC_COLLATE="en_US.US-ASCII"
LC_TIME="en_US.US-ASCII"
LC_NUMERIC="en_US.US-ASCII"
LC_MONETARY="en_US.US-ASCII"
LC_MESSAGES="en_US.US-ASCII"
LC_ALL=
```
and it's preventing me from using some software (one being my backup utility). What am I missing to get UTF8 working? I'm on FreeBSD 11.1


----------



## ShelLuser (Jun 13, 2018)

All of this is explained in Chapter 22 of the FreeBSD handbook.

You're not sharing full examples, if all you added were those two lines in login.conf and it didn't work then I can only assume that you used the wrong section. However, you're not showing this detail.

Although not recommended you could also chose to simply override the environment variables in your session. So, set them during login, where depends on your shell. Most common would be ~/.profile.

Now, the next comment won't necessarily help you but I can't help share some concern about the situation you're going to create here. I mean... a backup program which doesn't work due to a wrong locale really doesn't sound very reliable to me.

In fact, I would argue that it could become disruptive if not dangerous to rely on it because what's going to happen in an emergency where you booted your system using a rescue CD (thus using a default locale) and you now need this software to restore your environment as quickly as possible? First you'd be trying to set up the right locale, and only then would you be able to actually restore your data.

That is assuming you'll still remember how to set all this up manually at that time.

Food for thought perhaps?

Anyway, I hope this can help you.


----------



## stratacast1 (Jun 13, 2018)

I've thought about that locale issue too, I'm curious about why the utility requires UTF8 and can't operate without an ASCII locale. Beside the point though, I added them to the default section as stated in the FreeBSD handbook, I also did the same thing for my ~/.login_conf file according to the FreeBSD handbook. Oddly enough, there was different behavior between my X session and CLI. On CLI, UTF8 was applied properly, but oddly, the example (commented out) German lines in my ~/.login_conf were being read, so I commented those out, and then ensured that my X session was properly using the right locale, and it seems to be working now. I couldn't tell you exactly when things started working, I think it did all along, just didn't apply to my X session


----------



## stratacast1 (Jun 13, 2018)

ShelLuser if you're interested in knowing about the backup tool: the utility is Borg, which they are aware of the issue, reading their docs:

Important: JSON output is expected to be UTF-8, but currently borg depends on the locale being configured for that (must be a UTF-8 locale and _not_ “C” or “ascii”), so that Python will choose to encode to UTF-8. The same applies to any inputs read by borg, they are expected to be UTF-8 encoded also.

We consider this a bug (see #2273) and might fix it later, so borg will use UTF-8 independent of the locale.

Sounds like something specific to how Python is being used here.


----------

