The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

334

LC_ALL is the environment variable that overrides all the other localisation settings (except $LANGUAGE under some circumstances). Different aspects of localisations (like the thousand separator or decimal point character, character set, sorting order, month, day names, language or application messages like error messages, currency symbol) can be set using ...


209

It forces applications to use the default language for output: $ LC_ALL=es_ES man ¿Qué página de manual desea? $ LC_ALL=C man What manual page do you want? and forces sorting to be byte-wise: $ LC_ALL=en_US sort <<< $'a\nb\nA\nB' a A b B $ LC_ALL=C sort <<< $'a\nb\nA\nB' A B a b


79

en_IE.UTF-8 English (Ireland) locale has all the things you're asking for: Measurements metric — yes 24-hour time format — yes Work week starts on Monday — yes Numeric date in (something at least resembling) ISO format, yyyy-mm-dd — no, it this locale it's dd/mm/yy. But that seems close enough to what you're used to Informal date is ...


69

Note that when using range expressions like [a-z], letters of the other case may be included, depending on the setting of LC_COLLATE. LC_COLLATE is a variable which determines the collation order used when sorting the results of pathname expansion, and determines the behavior of range expressions, equivalence classes, and collating sequences within ...


68

No, it doesn't consider them as equivalent, they just have the same primary weight. So that, in first approximation, they sort the same. If you look at /usr/share/i18n/locales/iso14651_t1_common (as used as basis for most locales) on a GNU system (here with glibc 2.27), you'll see: <U0065> <e>;<BAS>;<MIN>;IGNORE # 259 e <U025B>...


62

Debian ships locales in source form. They need to be compiled explicitly. The reason for this is that compiled locales use a lot more disk space, but most people only use a few of them. Run dpkg-reconfigure locales as root, select the locales you want in the list (with your settings, you need en_GB and en_US.UTF-8 — I recommend selecting en_US and en_GB.UTF-...


43

Ask locale: locale decimal_point This will output the decimal point using the current locale settings. If you need the thousands separator: locale thousands_sep


31

locale-gen is not present in Centos/Fedora. You must use localedef: localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 From man localedef: NAME localedef - define locale environment SYNOPSIS localedef [-c][-f charmap][-i sourcefile][-u code_set_name] name DESCRIPTION The localedef utility shall convert source definitions for locale cate‐...


31

The same exact thing happened to me. Building on what Thomas said above, I was able to fix it by uncommenting en_US.UTF-8 UTF-8 in my /etc/locale.gen file (previously none of the lines had been uncommented), then running locale-gen.


29

That's a consequence of those characters having the same sorting order. You'll also notice that sort -u << EOF ■ ⅕ ⅖ ⅗ EOF returns only one line. Or that: expr ■ = ⅕ returns true (as required by POSIX). Most locales shipped with GNU systems have a number of characters (and even sequences of characters (collating sequences)) that have the same ...


28

Locale settings are user preferences that relate to your culture. Locale names On all current unix variants that I know of (but not on a few antiques), locale names follow the same pattern: An ISO 639-1 lowercase two-letter language code, or an ISO 639-2 three-letter language code if the language has no two-letter code. For example, en for English, de ...


26

You've tried to apply a recipe for Ubuntu under Debian. That usually works, but in this specific case it doesn't. Ubuntu is derived from Debian, and doesn't change much apart from the installer and the GUI. The locale-gen command is one of those few other things that it changes. I don't know why. Under Debian, the locale-gen command takes no arguments and ...


25

Short answer: restrictions imposed in Unix/Linux/BSD kernel, namei() function. Encoding takes place in user level programs like xterm, firefox or ls. I think you're starting from incorrect premises. A file name in Unix is a string of bytes with arbitrary values. A few values, 0x0 (ASCII Nul) and 0x2f (ASCII '/') are just not allowed, not as part of a ...


25

[A-Z] in bash matches all collating elements (characters but call also be sequence of characters like Dsz in Hungarian locales) that sort after A and sort before Z. In your locale, c probably sorts in-between B and C. $ printf '%s\n' A a á b B c C Ç z Z Ẑ | sort a A á b B c C Ç z Z Ẑ So c or z would be matched by [A-Z], but not Ẑ or a. $ printf '%s\n' A a ...


23

You can first remove all unneeded locales by doing: $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive Where ^en can be replaced by the locale you wish to keep Then $build-locale-archive If this gives you an error similar to $build-locale-archive /usr/sbin/build-locale-archive: cannot read archive header Then try this ...


22

It seems that no locale is generated. Have you selected pl_PL.UTF-8 properly in dpkg-reconfigure locales by pressing space in the corresponding line? If yes, the line pl_PL.UTF-8 UTF-8 in /etc/locale.gen is not commented (= does not start with #). If you need to fix this, you need also to run locale-gen to generate the locales. Its output should be: ...


20

Block size - GNU Coreutils says A block size specification preceded by ' causes output sizes to be displayed with thousands separators. (Note well that just specifying a block size is not enough). So depending on what you want, you could try BLOCK_SIZE="'1" ls -l BLOCK_SIZE="'1kB" ls -l or ls -l --block-size="'1" ls -l --block-size="'1kB" you can ...


20

The char type in C is one byte, but it's intended for ASCII characters; there are variable-width encodings like UTF-8 that can take up many bytes per character. wc uses the mbrtowc(3) function to decode multibyte sequences, depending on the locale set by the LC_CTYPE environment variable. If you set the locale properly, you should get the same result for all ...


19

Top rated solution didn't helped in my case, so I used this one: export LC_ALL="en_US.UTF-8" sudo dpkg-reconfigure locales After that, I logged out and logged in and error was missing.


18

You're missing a file which would be used to default the locale in the absence of $LANG or $LC_ALL (or all of the more specific $LC_whatever) being set. On older glibc, it's /usr/lib/locale/locale-archive. Because GNU/Linux is chaotic, you should use strace to determine which files are expected in the particular versions in use on your machine: strace -e ...


17

The thing is, the kernel doesn't care one bit how the applications interpret the data it is given as a filename. Let's imagine I have a C application that deals with exclusively UTF-16 strings. And I enter, via a properly configured input method, the ∯ symbol (Unicode 0x222F) into the "Save As" prompt/dialog. If the application doesn't do any form of ...


17

If your man is from the man-db package (man 2.x, like on most GNU/Linux distributions), the fastest way is to use the -L flag of man. You need just to know the abbreviation of the wanted locale. man -Len man # -> English man-page of man man -Lru man # -> Russian man-page of man If you use the other man implementation (man 1.x), the only way is to ...


17

Change the character translation in PuTTY to UTF-8.


16

If you don't care to mix lowercase and uppercase, set your locale to C, which takes characters in their numerical order. _ falls between uppercase and lowercase. $ LC_COLLATE=C ls BAR FOO _score _under hello world $ LC_COLLATE=en_US ls BAR FOO hello _score _under world The locale settings LC_MESSAGES (language of error ...


16

Looks like you are using a non-POSIX locale. Try: export LC_ALL=C and then sort. info sort clearly says: (1) If you use a non-POSIX locale (e.g., by setting `LC_ALL' to `en_US'), then `sort' may produce output that is sorted differently than you're accustomed to. In that case, set the `LC_ALL' environment variable to `C'. Note that setting only ...


16

At a guess, Your locale uses UTF-8 encoding, and About 10% of your file consists of characters which require more than one octet to encode into UTF-8. By the way, from man wc: -c, --bytes print the byte counts -m, --chars print the character counts


16

en_DE doesn’t exist as a default locale, so you can’t select English localised for German-speaking countries as a locale during installation. (Why should one use update-locale instead of directly setting LANGUAGE? describes the checks involved in choosing a locale.) There are two approaches to achieve what you’re after. One is to create a new locale with ...


15

I also had this same issue (Arch XFCE). Basically what happens is it switches input methods whenever you press Shift+Space, which frequently accidentally happens when typing. To fix this, you have to change or remove this hotkey: In a terminal window, type uim-pref-gtk, which is the settings for the UIM input method. Go to the Global key bindings 1 section. ...


15

The string comes from strerror(3), which maps error numbers to messages. In this case, it's mapping EACCES. The strings (and their translations) are contained in your C library.


15

man sort: *** WARNING *** The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values. So, try: LC_ALL=C sort file.txt


Only top voted, non community-wiki answers of a minimum length are eligible