generalized string conversion for libc

This commit is contained in:
Arvid Norberg 2011-02-22 03:09:13 +00:00
parent 97a40a45cd
commit 118a75ebe7
3 changed files with 13 additions and 3 deletions

View File

@ -142,6 +142,7 @@ POSSIBILITY OF SUCH DAMAGE.
#if defined __APPLE__ #if defined __APPLE__
#ifndef TORRENT_USE_ICONV #ifndef TORRENT_USE_ICONV
#define TORRENT_USE_ICONV 0 #define TORRENT_USE_ICONV 0
#define TORRENT_USE_LOCALE 0
#endif #endif
#endif #endif
#define TORRENT_HAS_FALLOCATE 0 #define TORRENT_HAS_FALLOCATE 0
@ -157,7 +158,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_MINGW #define TORRENT_MINGW
#define TORRENT_WINDOWS #define TORRENT_WINDOWS
#ifndef TORRENT_USE_ICONV #ifndef TORRENT_USE_ICONV
#define TORRENT_USE_ICONV 1 #define TORRENT_USE_ICONV 0
#define TORRENT_USE_LOCALE 1
#endif #endif
#define TORRENT_USE_RLIMIT 0 #define TORRENT_USE_RLIMIT 0
@ -169,6 +171,7 @@ POSSIBILITY OF SUCH DAMAGE.
// is necessary // is necessary
#ifndef TORRENT_USE_ICONV #ifndef TORRENT_USE_ICONV
#define TORRENT_USE_ICONV 0 #define TORRENT_USE_ICONV 0
#define TORRENT_USE_LOCALE 1
#endif #endif
#define TORRENT_USE_RLIMIT 0 #define TORRENT_USE_RLIMIT 0
#define TORRENT_HAS_FALLOCATE 0 #define TORRENT_HAS_FALLOCATE 0
@ -257,6 +260,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#define TORRENT_USE_ICONV 1 #define TORRENT_USE_ICONV 1
#endif #endif
#ifndef TORRENT_USE_LOCALE
#define TORRENT_USE_LOCALE 0
#endif
#ifndef TORRENT_BROKEN_UNIONS #ifndef TORRENT_BROKEN_UNIONS
#define TORRENT_BROKEN_UNIONS 0 #define TORRENT_BROKEN_UNIONS 0
#endif #endif

View File

@ -90,7 +90,7 @@ namespace libtorrent
TORRENT_EXPORT std::string convert_from_wstring(std::wstring const& s); TORRENT_EXPORT std::string convert_from_wstring(std::wstring const& s);
#endif #endif
#if defined TORRENT_WINDOWS || TORRENT_USE_ICONV #if TORRENT_USE_ICONV || TORRENT_USE_LOCALE
TORRENT_EXPORT std::string convert_to_native(std::string const& s); TORRENT_EXPORT std::string convert_to_native(std::string const& s);
TORRENT_EXPORT std::string convert_from_native(std::string const& s); TORRENT_EXPORT std::string convert_from_native(std::string const& s);
#else #else

View File

@ -657,7 +657,9 @@ namespace libtorrent
if (iconv_handle == iconv_t(-1)) return s; if (iconv_handle == iconv_t(-1)) return s;
return iconv_convert_impl(s, iconv_handle); return iconv_convert_impl(s, iconv_handle);
} }
#elif defined TORRENT_WINDOWS
#elif TORRENT_USE_LOCALE
std::string convert_to_native(std::string const& s) std::string convert_to_native(std::string const& s)
{ {
std::wstring ws; std::wstring ws;
@ -682,6 +684,7 @@ namespace libtorrent
libtorrent::wchar_utf8(ws, ret); libtorrent::wchar_utf8(ws, ret);
return ret; return ret;
} }
#endif #endif
} }