LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-14-2022, 01:03 AM   #1
davidzory
LQ Newbie
 
Registered: Jan 2017
Posts: 4

Rep: Reputation: Disabled
debian has C.UTF-8 locale, centos reports as C.utf8


Using locale -a on debian:

Quote:
# locale -a
C
C.UTF-8
POSIX
but on centos:

Quote:
# locale -a
C
C.utf8
POSIX
This came about in a bash script I was writing where I had to check if the C.UTF-8 locale existed so I could fallback to en_US.utf8 if not because of distros like arch that don't have UTF-8.

Because I was doing something like locale -a | grep -i UTF-8 it was returning false on centos because over there its called C.utf8 without the dash.

Once I discovered the naming different I was about to account for it in my script... but why the inconsistency? How does this not trip up programs from distro to distro, is there a better way to inspect locales instead of locale -a?
 
Old 08-14-2022, 03:28 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,927

Rep: Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043Reputation: 5043
I believe glibc strips any hyphen(s) and converts case before using the specified locale string. If you're writing scripts that act on $LANG, $LC_ALL or one of the other locale related variables it might be wise to follow suit.

As for why the inconsistency exists at all, I have no idea. All I can guess is that as the specifier after the dot represents a codeset and codesets are traditionally written in upper case letters Debian followed suit with the locale names, but Redhat didn't.

The UNIXverse, is full of inconsistencies.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot lock locale archive "/usr/lib64/locale/locale-archive": Permission denied when building Multilib Cross Linux from Scratch Gunnersky2002 Linux - Software 2 06-13-2018 09:28 AM
[SOLVED] UTF-8, not utf-8 or utf8 in locale setting to have SCIM working? Didier Spaier Slackware 8 10-16-2015 01:56 AM
GTK1 not understanging UTF8?, LANG=pl_PL.UTF-8 qs-raven Linux - Software 5 12-03-2006 08:31 AM
X11 / UTF-8 locale seems missing 'fr_FR.UTF-8' chrsitophermann Debian 11 07-17-2004 02:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration