fix iconv use on mingw

This commit is contained in:
Arvid Norberg 2011-07-23 19:30:23 +00:00
parent 1b353ce5af
commit ff6da81c4c
2 changed files with 9 additions and 2 deletions

View File

@ -167,6 +167,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_USE_ICONV 0
#define TORRENT_USE_LOCALE 1
#endif
#define TORRENT_ICONV_ARG (const char**)
#define TORRENT_USE_RLIMIT 0
#define TORRENT_USE_NETLINK 0
#define TORRENT_USE_GETADAPTERSADDRESSES 1
@ -276,6 +277,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#define TORRENT_UPNP_LOGGING
#endif
#ifndef TORRENT_ICONV_ARG
#define TORRENT_ICONV_ARG (char**)
#endif
// libiconv presence, not implemented yet
#ifndef TORRENT_USE_ICONV
#define TORRENT_USE_ICONV 1

View File

@ -621,8 +621,10 @@ namespace libtorrent
ret.resize(outsize);
char const* in = s.c_str();
char* out = &ret[0];
// posix has a weird iconv signature
size_t retval = iconv(h, (char**)&in, &insize,
// posix has a weird iconv signature. implementations
// differ on what this signature should be, so we use
// a macro to let config.hpp determine it
size_t retval = iconv(h, TORRENT_ICONV_ARG &in, &insize,
&out, &outsize);
if (retval == (size_t)-1) return s;
// if this string has an invalid utf-8 sequence in it, don't touch it