aboutsummaryrefslogtreecommitdiffstats
path: root/src/charConv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charConv.c')
-rw-r--r--src/charConv.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/charConv.c b/src/charConv.c
index c9a47fe1d..26e4bddeb 100644
--- a/src/charConv.c
+++ b/src/charConv.c
@@ -93,6 +93,22 @@ int setCharSetConversion(const char *to, const char *from)
#endif
}
+#ifdef HAVE_ICONV
+static inline size_t deconst_iconv(iconv_t cd,
+ const char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft)
+{
+ union {
+ const char **a;
+ char **b;
+ } deconst;
+
+ deconst.a = inbuf;
+
+ return iconv(cd, deconst.b, inbytesleft, outbuf, outbytesleft);
+}
+#endif
+
char *char_conv_str(char *dest, const char *string)
{
if (!char_conv_to)
@@ -117,8 +133,8 @@ char *char_conv_str(char *dest, const char *string)
bufferPtr = buffer;
outleft = BUFFER_SIZE;
err =
- iconv(char_conv_iconv, &string, &inleft, &bufferPtr,
- &outleft);
+ deconst_iconv(char_conv_iconv, &string, &inleft,
+ &bufferPtr, &outleft);
if (outleft == BUFFER_SIZE
|| (err == (size_t)-1L && errno != E2BIG)) {
return NULL;