Ver Fonte

updated: Proper way to handle the iconv call.

The call modifies output.
Steve Thielemann há 4 anos atrás
pai
commit
facaf8cbf2
1 ficheiros alterados com 5 adições e 3 exclusões
  1. 5 3
      images.cpp

+ 5 - 3
images.cpp

@@ -14,9 +14,11 @@ public:
   int convert(char *input, char *output, size_t outbufsize) {
     size_t inbufsize = strlen(input);
     size_t orig_size = outbufsize;
-    memset(output, 0, outbufsize);
-
-    return iconv(ic, &input, &inbufsize, &output, &outbufsize);
+    // memset(output, 0, outbufsize);
+    // https://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.15/iconv.3.html
+    int r = iconv(ic, &input, &inbufsize, &output, &outbufsize);
+    *output = 0;
+    return r;
   }
 };