#include #include #include #include #include #include "internal.h" #include "rcciconv.h" static void rccIConvCopySymbol(char **in_buf, int *in_left, char **out_buf, int *out_left) { if ((out_left>0)&&(in_left>0)) { (**out_buf)=(**in_buf); (*out_buf)++; (*in_buf)++; (*in_left)--; (*out_left)--; } } static int rccIConvUTFBytes(unsigned char c) { int j; if (c<128) return 1; for (j=6;j>=0;j--) if ((c&(1<tmpbuffer; out_left = RCC_MAX_STRING_CHARS; loop: err=iconv(icnv, &in_buf, &in_left, &out_buf, &out_left); if (err<0) { if (errno==E2BIG) { *(int*)(ctx->tmpbuffer+(RCC_MAX_STRING_CHARS-sizeof(int)))=0; } else if (errno==EILSEQ) { if (errors++0;ub--) rccIConvCopySymbol(&in_buf, &in_left, &out_buf, &out_left); if (in_left>0) goto loop; } else if (!utf_mode) { utf_mode = 1; goto loop_restart; } else { return -1; } } else { return -1; } } ctx->tmpbuffer[RCC_MAX_STRING_CHARS - out_left] = 0; return RCC_MAX_STRING_CHARS - out_left; }