locale.c: Fix failure to find UTF-8 locales
Commit
119ee68b changed the method to determine if a locale is a UTF-8
one to a method that was usable on more platforms, by using the C99 libc
function mbtowc(). I didn't realize that there needs to be a special
call to this function preceeding the main call to make sure it is in the
initial state. This commit fixes that.
In looking at the results from several different platforms, I decided it
is best to use nl_langinfo() in preference to mbtowc() when available,
and only use mbtowc() if nl_langinfo doesn't exist on the platform or
fails to return a real result, which happens for some locales on Darwin.
This commit does that as well.