summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/strutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-09-23 17:11:41 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-09-23 17:11:41 +0200
commitf7d6459db697c6dbba8e5d787a817e7721bfb577 (patch)
treedf35974a4902758ad2e9e03720a463bc13bdefb4 /apt-pkg/contrib/strutl.cc
parent73b1d4847befc0d3042b6689484e0f74667aba6e (diff)
parenta874991b8549397fb26c47bbf229854556a3fb60 (diff)
merged from david, many thanks
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r--apt-pkg/contrib/strutl.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 1683868c8..4c05f2df8 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -67,9 +67,20 @@ bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest)
outbuf = new char[insize+1];
outptr = outbuf;
- iconv(cd, &inptr, &insize, &outptr, &outsize);
- *outptr = '\0';
+ while (insize != 0)
+ {
+ size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize);
+ if (err == (size_t)(-1))
+ {
+ insize--;
+ outsize++;
+ inptr++;
+ *outptr = '?';
+ outptr++;
+ }
+ }
+ *outptr = '\0';
*dest = outbuf;
delete[] outbuf;