]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/strutl.cc
* apt-pkg/deb/debindexfile.cc, apt-pkg/pkgcachegen.cc:
[apt.git] / apt-pkg / contrib / strutl.cc
index 1683868c8a398c72fb9a0e61d97233d3ac0fa56c..4c05f2df880a2200f7872d863fbdeef425f4dd75 100644 (file)
@@ -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;