Index: mapstring.c
===================================================================
--- mapstring.c	(revision 9975)
+++ mapstring.c	(working copy)
@@ -1445,6 +1445,7 @@
 #ifdef USE_ICONV
   iconv_t cd = NULL;
   const char *inp;
+  char* errormessage = NULL;
   char *outp, *out = NULL;
   size_t len, bufsize, bufleft, iconv_status;
 
@@ -1480,7 +1481,24 @@
 
   while (len > 0){
     iconv_status = iconv(cd, (char**)&inp, &len, &outp, &bufleft);
-    if(iconv_status == -1){
+    if(iconv_status == (size_t)-1) {
+      switch (errno) {
+          case E2BIG:
+          errormessage = "There is not sufficient room in buffer";
+          break;
+          case EILSEQ:
+          errormessage = "An invalid multibyte sequence has been encountered in the input";
+          break;
+          case EINVAL:
+          errormessage = "An incomplete multibyte sequence has been encountered in the input";
+          break;
+          default:
+          errormessage = "Unknown";
+          break;
+      }
+      msSetError(MS_MISCERR, "Unable to convert string in encoding '%s' to UTF8: %s",
+                "msGetEncodedString()",
+                encoding,errormessage);
       msFree(out);
       iconv_close(cd);
       return strdup(string);
@@ -1555,7 +1573,7 @@
                     errormessage = "Unknown";
                     break;
                 }
-                msSetError(MS_MISCERR, "Unable to convert string in encoding '%s' to UTF8 %s",
+                msSetError(MS_MISCERR, "Unable to convert string in encoding '%s' to UTF8: %s",
                                        "msConvertWideStringToUTF8()",
                            encoding,errormessage);
                 iconv_close(cd);

