Make locale_charset() use nl_langinfo() so that it would work
properly. For example:
$ idn2 --debug ''
Charset: en_US.UTF-8
idn2: toAscii: could not convert string to UTF-8
$ LD_PRELOAD=$PREFIX/local/lib/libunistring.so idn2 --debug ''
Charset: UTF-8
$