- iconv(cd_to_internal, &rdptr, &insize, &wrptr, &outsize);
+ /* do the conversion */
+ iconv(cd_to_internal, &rdptr, &conv_buf_size, &wrptr, &outsize);
+ /* then shift what is left over to the head of the input buffer */
+ memmove(conv_buf, rdptr, conv_buf_size);
+ memset(conv_buf + conv_buf_size, 0, sizeof(conv_buf) - conv_buf_size);