Fix iconv in eglib, remove GNU libiconv-ism
commitb0ab59fa93c9e6f65fa4313cf4d3ec6d00c14cdd
authorCalvin Buckley <calvin@cmpct.info>
Sun, 12 Aug 2018 00:02:34 +0000 (11 20:02 -0400)
committerCalvin Buckley <calvin@cmpct.info>
Sun, 12 Aug 2018 00:02:34 +0000 (11 20:02 -0400)
tree04cbfacbaeaf6af2144d68788672536282dc43e9
parent37b78f0640931681cd4043b63e42c7421982a52d
Fix iconv in eglib, remove GNU libiconv-ism

iconv in eglib was broken due to a broken define. Also fix linking
of iconv when iconv isn't in libc.

Also remove the usage of a GNU libcharset specific function and rely
on a standard POSIX function that outputs the same value on every
modern Unixoid I've tried it on. (Ubuntu/macOS/i/FreeBSD)

This comment explains a lot of things for the latter:

```c
/*
 * This function used used to use the "locale_charset" call in
 * libiconv's libcharset library. However, this isn't always
 * available on some systems, including ones with GNU libc. So,
 * instead use a function that's a standard part of POSIX2008.
 *
 * nl_langinfo is in POSIX2008 and should be on any sane modern
 * Unix. With a UTF-8 locale, it should return "UTF-8" - this
 * has been verified with Ubuntu 18.04, FreeBSD 11, and i 7.3.
 *
 * The motivation for using locale_charset was likely due to
 * the cruftiness of Unices back in ~2001; where you had to
 * manually query environment variables, and the values were
 * inconsistent between each other. Nowadays, if Linux, macOS,
 * AIX/PASE, and FreeBSD can all return the same values for a
 * UTF-8 locale, we can just use the value directly.
 *
 * It should be noted that by default, this function will give
 * values for the "C" locale, unless `setlocale (LC_ALL, "")`
 * is ran to init locales - driver.c in mini does this for us.
 */
```
configure.ac
mono/eglib/giconv.c
mono/eglib/gunicode.c