Encoding set to "text" iso "utf8" whereas LC_CTYPE=UTF-8

Hello,

I am encountering some encoding issues that seem to originate from the default encoding (i.e. if I set “:- encoding(utf8).” in the respective source file als works fine). In my case the default encoding is set to “text”. However, I expected it to be utf8 as the the locale LC_CTYPE is set to UTF-8. So my question is if this is indeed an error? And if so, how to correct it? Any help is appreciated.

    > % uname -a

    Darwin scissors 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64

    >  % env
    TERM_PROGRAM=Apple_Terminal
    SHELL=/bin/zsh
    TERM=xterm-256color
    TMPDIR=/var/folders/4s/3c4qf09x2zd8s68rn6bmfmjm00lv_b/T/
    TERM_PROGRAM_VERSION=433
    ...
    LC_CTYPE=UTF-8
    _=/usr/bin/env

    > % swipl

    Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.24-9-g42b97ff65)
    SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
    Please run ?- license. for legal details.
    For online help and background, visit [https://www.swi-prolog.org](https://www.swi-prolog.org/)
    For built-in help, use ?- help(Topic). or ?- apropos(Word).

    ?- current_prolog_flag(encoding,X).
    X = text.

Thanks,

Joost

It does not need to be an issue. text means Prolog will use the C library multibyte to Unicode translation functions. utf8 means Prolog understands the encoding is UTF-8 and uses its own (generally faster) conversion.

See initEncoding() in src/os/pl-ctype.c. This expects locales named lang.encoding instead of simply encoding. On my Mac the LC_CTYPE is set to en_GB.UTF-8. Not sure where this comes from. Any idea where your plain UTF-8 comes from?

There is an option “set locale environment variables on startup” in the terminal app (zsh) > preferences > advanced

Turning it off eliminates the setting of LC_CTYPE=UTF-8

Adding export LANG=en_US.UTF-8 to ~/.zshrc seems to set the locale correctly

% locale

LANG=“en_US.UTF-8”

LC_COLLATE=“en_US.UTF-8”

LC_CTYPE=“en_US.UTF-8”

LC_MESSAGES=“en_US.UTF-8”

LC_MONETARY=“en_US.UTF-8”

LC_NUMERIC=“en_US.UTF-8”

LC_TIME=“en_US.UTF-8”

LC_ALL=

?- current_prolog_flag(encoding,X).

X = utf8.

Thanks,

Joost

Looks like a bug in the zsh app to me. According to locale -a on my Mac, Apple calls the locales lang.UTF-8 and there is no plain UTF-8 locale.