Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8
Good day,
I realize we can't support every distribution, but wanted to mention an odd warning affecting xxdiff on at least Mabox (possibly Manjaro, Arch Linux.) Mabox can be found here: https://maboxlinux.org It is a rolling-release, so is up-to-date.
When xxdiff v5.1 (Qt 6.7.2) is installed in Mabox via the pamac installer (repo), it seems to run fine but always gives this warning:
Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual for more information.
Thinking my locales were messed up, checked locale:
me@mine ~ $ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
Nothing is set to =C so unsure where xxdiff thinks the locales are mis-set. This is the first time I've seen this message on this box, ever.
I've not saved a file with xxdiff yet, because want to use it to compare .conf files with .pacnew and .pacsave backups (and merge changes.) Those files are created from pamac when it detects new conf files (as opposed to just overwriting them.)
Further, a friend tried sudo apt install xxdiff (assuming Debian) and they do not get this message; it runs as expected.
Is there some quirk with locales only in Arch / Manjaro / Mabox? And is this completely benign, or will it save my files in C.UTF-8? Searching, seem to find a few users with similar issues stemming from a newer Qt.
Thanks for the consideration, have a great day.
Thanks mj. I won't have resources to look into this. This is most like related to this bit:
static char s_env_string_LC_ALL[] = "LC_ALL=C";
//------------------------------------------------------------------------------
//
int main( int argc, char** argv, char** envp )
{
...
// Override user locale or xxdiff could not parse localized diff output...
putenv(s_env_string_LC_ALL);
I have no idea why I wrote this at the time (it's >20 years ago). I was probably just being temporarily dumb. You can try commenting out and testing, see how the problem I alluded manifests.
The same warning is reported on my Fedora 40 box as well (also Qt 6.7.2).
FYI: I binary-patched LC_ALL=C to LX_ALL=C in the xxdiff version I just compiled on Fedora 41 (due to being lazy to recompile), and that warning message went away (with emacs and in overwrite mode that was easy)...
There may be reason that option has been used in xxdiff 2 and xxdiff 3 times (qt2/3 did not know much of utf-8 :D) -- but one cannot be sure what happens when that is removed.
I've been building xxdiff 3, and there I added LANG=C alongside the LC_ALL=C to fix problem when
attempting to open files which names had utf-8 chars in it.
Same problem on Slackware64 15.0
The comment in main.cpp
// Override user locale or xxdiff could not parse localized diff output...
provides some insight as to why it is there, and yet when I commented out the definition and the putenv() and did a couple of tests, I didn't see any problems. Maybe only for people with something weird in their locale setup?