When I execute locale -a
on my Mac Book (macOS 14.4.1, Apple silicon), I can't find C.UTF-8
(though there are en_US.UTF-8
, fr_FR.UTF-8
, etc. And there are also C
and POSIX
, without specific encodings). At the same time, when I execute locale -a
on my Ubuntu machine, I can find C.UTF-8
.
Also on my Mac Book, the default locale
is:
LANG=""LC_COLLATE="C"LC_CTYPE="UTF-8"LC_MESSAGES="C"LC_MONETARY="C"LC_NUMERIC="C"LC_TIME="C"LC_ALL=
But after I execute export LC_ALL=C.UTF-8
, the locale
is
LANG=""LC_COLLATE="C"LC_CTYPE="C"LC_MESSAGES="C"LC_MONETARY="C"LC_NUMERIC="C"LC_TIME="C"LC_ALL="C"
I just want to make sure when executing my shell script the encoding is UTF-8, because my script will calculate the length of a variable. But on my Mac Book, it seems that I can't add export LC_ALL=C.UTF-8
at the beginning of my script?
(I know I can add export LC_ALL=en_US.UTF-8
or export LC_CTYPE=en_US.UTF-8
at the beginning, because I don't care the values of other LC_*
. I just require LC_CTYPE
to be UTF-8. But this workaround is not elegant IMO...)