This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Use REPLACEMENT_CHARACTER as a test
This is trying to determine if the locale is UTF-8. The easiest way to
tell is if the codeset returned by nl_langinfo says UTF-8, but if that
fails or nl_langinfo() is not present on the system, a fallback method
is to use the libc routines to convert a known byte string to code point
and see if that matches the expected Unicode code point. Prior to this
patch, the byte string representing HYPHEN was used. That's probably
good enough, but we can do better with no extra work. This commit
changes to use the REPLACEMENT CHARACTER instead. That is a Unicode
concept. The chances of a non-UTF-8 locale taking the UTF-8 byte string
for the REPLACEMENT and evaluating to REPLACEMENT are vanishingly small.