|
a/src/utils/transcode.cpp |
|
b/src/utils/transcode.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: transcode.cpp,v 1.6 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: transcode.cpp,v 1.7 2006-03-29 11:18:15 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
38 |
#else
|
38 |
#else
|
39 |
#define CHARPP
|
39 |
#define CHARPP
|
40 |
#endif
|
40 |
#endif
|
41 |
|
41 |
|
42 |
bool transcode(const string &in, string &out, const string &icode,
|
42 |
bool transcode(const string &in, string &out, const string &icode,
|
43 |
const string &ocode)
|
43 |
const string &ocode, int *ecnt)
|
44 |
{
|
44 |
{
|
45 |
iconv_t ic;
|
45 |
iconv_t ic;
|
46 |
bool ret = false;
|
46 |
bool ret = false;
|
47 |
const int OBSIZ = 8192;
|
47 |
const int OBSIZ = 8192;
|
48 |
char obuf[OBSIZ], *op;
|
48 |
char obuf[OBSIZ], *op;
|
49 |
bool icopen = false;
|
49 |
bool icopen = false;
|
50 |
|
50 |
if (ecnt)
|
|
|
51 |
*ecnt = 0;
|
51 |
out.erase();
|
52 |
out.erase();
|
52 |
size_t isiz = in.length();
|
53 |
size_t isiz = in.length();
|
53 |
out.reserve(isiz);
|
54 |
out.reserve(isiz);
|
54 |
const char *ip = in.c_str();
|
55 |
const char *ip = in.c_str();
|
55 |
|
56 |
|
|
... |
|
... |
77 |
LOGDEB(("transcode:iconv: bad input seq.: shift, retry\n"));
|
78 |
LOGDEB(("transcode:iconv: bad input seq.: shift, retry\n"));
|
78 |
LOGDEB1((" Input consumed %d output produced %d\n",
|
79 |
LOGDEB1((" Input consumed %d output produced %d\n",
|
79 |
ip - in.c_str(), out.length() + OBSIZ - osiz));
|
80 |
ip - in.c_str(), out.length() + OBSIZ - osiz));
|
80 |
out.append(obuf, OBSIZ - osiz);
|
81 |
out.append(obuf, OBSIZ - osiz);
|
81 |
out += "?";
|
82 |
out += "?";
|
|
|
83 |
if (ecnt)
|
|
|
84 |
(*ecnt)++;
|
82 |
ip++;isiz--;
|
85 |
ip++;isiz--;
|
83 |
continue;
|
86 |
continue;
|
84 |
}
|
87 |
}
|
85 |
goto error;
|
88 |
goto error;
|
86 |
}
|
89 |
}
|