summaryrefslogtreecommitdiffstats
path: root/src/rcciconv.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 08:45:46 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 08:45:46 +0000
commitf15620c372b8813a87d07eee169cf2096c99c173 (patch)
treef1c59f41d4a9c9f5f45595695327b0e4a74b1408 /src/rcciconv.c
parent7233ff9095194b38586ce438379f08691a0fecdd (diff)
downloadlibrcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.gz
librcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.bz2
librcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.xz
librcc-f15620c372b8813a87d07eee169cf2096c99c173.zip
IConv and DB4
Diffstat (limited to 'src/rcciconv.c')
-rw-r--r--src/rcciconv.c48
1 files changed, 3 insertions, 45 deletions
diff --git a/src/rcciconv.c b/src/rcciconv.c
index 0fb440f..1add9d9 100644
--- a/src/rcciconv.c
+++ b/src/rcciconv.c
@@ -92,49 +92,7 @@ loop:
return outsize - out_left;
}
-
-
-size_t rccIConv(rcc_context ctx, iconv_t icnv, const char *buf, size_t len) {
- char *in_buf, *out_buf, *res, err;
- int in_left, out_left, olen;
- int ub, utf_mode=0;
- int errors=0;
-
- if ((!buf)||(!ctx)||(icnv == (iconv_t)-1)) return (size_t)-1;
-
- len = STRNLEN(buf,len);
-
- if (iconv(icnv, NULL, NULL, NULL, NULL) == -1) return (size_t)-1;
-
-loop_restart:
- errors = 0;
- in_buf = (char*)buf; /*DS*/
- in_left = len;
- out_buf = ctx->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++<RCC_MAX_ERRORS) {
- for (ub=utf_mode?rccIConvUTFBytes(*in_buf):1;ub>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 (size_t)-1;
- }
- } else {
- return (size_t)-1;
- }
- }
-
- ctx->tmpbuffer[RCC_MAX_STRING_CHARS - out_left] = 0;
-
- return RCC_MAX_STRING_CHARS - out_left;
+size_t rccIConv(rcc_context ctx, rcc_iconv icnv, const char *buf, size_t len) {
+ if (!ctx) return (size_t)-1;
+ return rccIConvRecode(icnv, ctx->tmpbuffer, RCC_MAX_STRING_CHARS, buf, len);
}