]> 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 a991b8988472a7c6c5afe370004b1fe8514e19f6..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;
   
@@ -304,13 +315,13 @@ string SizeToStr(double Size)
    {
       if (ASize < 100 && I != 0)
       {
-         sprintf(S,"%.1f%c",ASize,Ext[I]);
+         sprintf(S,"%'.1f%c",ASize,Ext[I]);
         break;
       }
       
       if (ASize < 10000)
       {
-         sprintf(S,"%.0f%c",ASize,Ext[I]);
+         sprintf(S,"%'.0f%c",ASize,Ext[I]);
         break;
       }
       ASize /= 1000.0;