locale.c: Fix failure to find UTF-8 locales
authorKarl Williamson <public@khwilliamson.com>
Wed, 29 Jan 2014 23:44:27 +0000 (16:44 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 30 Jan 2014 00:15:15 +0000 (17:15 -0700)
commit1d958db20afb78823396dfee8e55ed9c90a0e548
tree341f5214f06cb96503a724a002f592c5885cda0b
parentb9df08e4b89fc268daccd0f9f31cc74c54dc9bf0
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.
locale.c