int csync_set_iconv_codec(const char *from) { c_close_iconv(); if (from != NULL) { c_setup_iconv(from); } return 0; }
static char *c_iconv(const char* str, enum iconv_direction dir) { #ifdef HAVE_ICONV_CONST const char *in = str; #else char *in = discard_const(str); #endif size_t size; size_t outsize; char *out; char *out_in; size_t ret; if (str == NULL) { return NULL; } if(_iconvs.from == NULL && _iconvs.to == NULL) { #ifdef __APPLE__ c_setup_iconv("UTF-8-MAC"); #else return c_strdup(str); #endif } size = strlen(in); outsize = size*2; out = c_malloc(outsize); out_in = out; if (dir == iconv_to_native) { ret = iconv(_iconvs.to, &in, &size, &out, &outsize); } else { ret = iconv(_iconvs.from, &in, &size, &out, &outsize); } if (ret == (size_t)-1) { SAFE_FREE(out_in); return NULL; } return out_in; }