---
name: "u8loc"
section: "1"
platform: "linux"
package: "u8loc"
version: "1.0.3-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/u8loc"
---

# u8loc(1)

run a program in a UTF-8-capable environment

## NAME

**u8loc** – run a program in a UTF-8-capable environment

## SYNOPSIS

**u8loc** \[**-p**\] **-r** *program* \[*args...*\]

**u8loc** \[**-p**\] **-q** **LC\_ALL**

**u8loc** \[**-p**\] **-q** **LANGUAGE**

**u8loc** **-q** **preferred**

**u8loc** **-q** **list**

**u8loc** **-****-features**

## DESCRIPTION

The **u8loc** utility prepares the environment variables so that a child process being run will hopefully generate clean UTF-8 output. It is designed to be run by a program that expects to be able to reliably parse the output of another program without worrying about character set conversions.

The **u8loc** utility invokes the [locale(1)](/locale/1.md) tool to list the names of the locales for which the current system has valid definitions, and then filters and reorders those names based on either a predefined list of language preferences or, if the **-p** option is specified, on the language names found in the current environment's locale-related variables (LC\_ALL, LANG, LC\_MESSAGES, LC\_CTYPE, etc.).

The **u8loc** utility accepts the following command-line options:

- **-p**

  Examine the current environment's locale-related variables and use the names of languages found there as a preference list for choosing a suitable locale.

- **-q**

  Do not execute a program; output the detected environment settings instead, depending on the supplied argument:

  - LC\_ALL

    Output the selected UTF-8-capable locale name that would be placed into the LC\_ALL environment variable.

  - LANGUAGE

    Output the empty string that would be placed into the LANGUAGE environment variable.

  - **list**

    List the available parameters for the **-q** option.

  - **preferred**

    Output the list of languages gathered from examining the locale-related environment variables.

- **-r**

  Set the LC\_ALL and LANGUAGE variables in the environment and execute the specified program.

## ENVIRONMENT

If the **-p** option is specified, the locale-related environment variables are examined in order. If any of them contains the name of a locale that specifies UTF-8 as encoding (by either a “UTF-8 or “utf8 suffix””), the language name is added to the list of preferences. The variables examined are:

- \* LC\_ALL

  - \* LANG

  - \* LC\_MESSAGES

  - \* LC\_COLLATE

  - \* LC\_NAME

  - \* LC\_IDENTIFICATION

  - \* LC\_CTYPE

  - \* LC\_NUMERIC

  - \* LC\_TIME

  - \* LC\_MONETARY

  - \* LC\_PAPER

  - \* LC\_ADDRESS

  - \* LC\_TELEPHONE

  - \* LC\_MEASUREMENT

  ## EXIT STATUS

If an error occurs during the detection of a suitable UTF-8-capable locale, the **u8loc** utility will exit with a non-zero error code. If the **-r** option is specified, the specified program will be executed and replace the **u8loc** process.

## EXAMPLES

Output the name of a UTF-8-capable locale:

```
u8loc -q LC_ALL
```

Run a program in a UTF-8-friendly environment:

```
u8loc -r -- cal -3
```

## STANDARDS

No standards documentation was harmed in the process of creating **u8loc**.

## BUGS

Please report any bugs in **u8loc** to the author.

## AUTHOR

The **u8loc** utility was written by Peter Pentchev ⟨roam@ringlet.net⟩.
