Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 376 of file icy2utf8.c.
Referenced by mpg123_icy2utf8(), and mpg123_store_utf8().
{ const uint8_t *s = (const uint8_t *)src; size_t srclen, dstlen, i, k; uint8_t ch, *d; char *dst; /* Some funny streams from Apple/iTunes give ICY info in UTF-8 already. So, be prepared and don't try to re-encode such. Unless forced. */ if(!force && is_utf8(src)) return (strdup(src)); srclen = strlen(src) + 1; /* allocate conservatively */ if ((d = malloc(srclen * 3)) == NULL) return (NULL); i = 0; dstlen = 0; while (i < srclen) { ch = s[i++]; k = tblofs[ch]; while (k < tblofs[ch + 1]) d[dstlen++] = cp1252_utf8[k++]; } /* dstlen includes trailing NUL since srclen also does */ if ((dst = realloc(d, dstlen)) == NULL) { free(d); return (NULL); } return (dst); }