summaryrefslogtreecommitdiff
path: root/src/unicode.c
diff options
context:
space:
mode:
authorGerrit Niezen <gerrit@tidepool.org>2020-05-29 14:20:48 +0100
committerGerrit Niezen <gerrit@tidepool.org>2020-05-29 14:20:48 +0100
commit3af1d507db1bad5c0924706c175a0098458cf536 (patch)
tree9e15509b211eb77b10edf2d575385bd95a65b41e /src/unicode.c
parent17d9c02e11f4e18c66c52a74d5f3c9b5c301d434 (diff)
downloadlibmtp-3af1d507db1bad5c0924706c175a0098458cf536.tar.gz
only convert if iconv and langinfo.h is available (#20)
Diffstat (limited to 'src/unicode.c')
-rw-r--r--src/unicode.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/unicode.c b/src/unicode.c
index 2adc94e..cb686c6 100644
--- a/src/unicode.c
+++ b/src/unicode.c
@@ -35,8 +35,6 @@
#include <string.h>
#ifdef HAVE_ICONV
#include "iconv.h"
-#else
-#error "libmtp unicode.c needs fixing to work without iconv()!"
#endif
#include "libmtp.h"
#include "unicode.h"
@@ -87,12 +85,14 @@ char *utf16_to_utf8(LIBMTP_mtpdevice_t *device, const uint16_t *unicstr)
size_t convmax = STRING_BUFFER_LENGTH*3;
loclstr[0]='\0';
+ #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
/* Do the conversion. */
nconv = iconv(params->cd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax);
if (nconv == (size_t) -1) {
// Return partial string anyway.
*locp = '\0';
}
+ #endif
loclstr[STRING_BUFFER_LENGTH*3] = '\0';
// Strip off any BOM, it's totally useless...
if ((uint8_t) loclstr[0] == 0xEFU && (uint8_t) loclstr[1] == 0xBBU && (uint8_t) loclstr[2] == 0xBFU) {
@@ -122,9 +122,11 @@ uint16_t *utf8_to_utf16(LIBMTP_mtpdevice_t *device, const char *localstr)
unicstr[0]='\0';
unicstr[1]='\0';
+ #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
/* Do the conversion. */
nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen, &unip, &convmax);
-
+ #endif
+
if (nconv == (size_t) -1) {
// Return partial string anyway.
unip[0] = '\0';