Fix src/util/string.cpp on NetBSD
- iconv() prototype changed from traditional Unix defintion to POSIX definition in 9.99.x. - wchar_t is not a valid character set for iconv. Share code with Android for using UTF-32.
This commit is contained in:
parent
e79d6154fc
commit
2628316842
@ -39,8 +39,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_ICONV_H_) && (defined(__FreeBSD__) || defined(__NetBSD__) || \
|
#ifdef __NetBSD__
|
||||||
defined(__OpenBSD__) || defined(__DragonFly__))
|
#include <sys/param.h>
|
||||||
|
#if __NetBSD_Version__ <= 999001500
|
||||||
|
#define BSD_ICONV_USED
|
||||||
|
#endif
|
||||||
|
#elif defined(_ICONV_H_) && (defined(__FreeBSD__) || defined(__OpenBSD__) || \
|
||||||
|
defined(__DragonFly__))
|
||||||
#define BSD_ICONV_USED
|
#define BSD_ICONV_USED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -79,6 +84,14 @@ static bool convert(const char *to, const char *from, char *outbuf,
|
|||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
// On Android iconv disagrees how big a wchar_t is for whatever reason
|
// On Android iconv disagrees how big a wchar_t is for whatever reason
|
||||||
const char *DEFAULT_ENCODING = "UTF-32LE";
|
const char *DEFAULT_ENCODING = "UTF-32LE";
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
// NetBSD does not allow "WCHAR_T" as a charset input to iconv.
|
||||||
|
#include <sys/endian.h>
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
const char *DEFAULT_ENCODING = "UTF-32BE";
|
||||||
|
#else
|
||||||
|
const char *DEFAULT_ENCODING = "UTF-32LE";
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
const char *DEFAULT_ENCODING = "WCHAR_T";
|
const char *DEFAULT_ENCODING = "WCHAR_T";
|
||||||
#endif
|
#endif
|
||||||
@ -94,7 +107,7 @@ std::wstring utf8_to_wide(const std::string &input)
|
|||||||
std::wstring out;
|
std::wstring out;
|
||||||
out.resize(outbuf_size / sizeof(wchar_t));
|
out.resize(outbuf_size / sizeof(wchar_t));
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#if defined(__ANDROID__) || defined(__NetBSD__)
|
||||||
SANITY_CHECK(sizeof(wchar_t) == 4);
|
SANITY_CHECK(sizeof(wchar_t) == 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user