#include <string.h>
 #include <stdlib.h>
 
+#ifndef __WXMSW__
+#include <errno.h>
+#endif
+
 #ifdef __SALFORDC__
   #include <clib.h>
 #endif
         // vsnprintf() may return either -1 (traditional Unix behaviour) or the
         // total number of characters which would have been written if the
         // buffer were large enough
-        if ( len >= 0 && len <= size )
+        // also, it may return an errno may be something like EILSEQ,
+        // in which case we need to break out
+        if ( (len >= 0 && len <= size)
+        // No EOVERFLOW on Windows nor Palm 6.0 nor OpenVMS
+#if !defined(__WXMSW__) && !defined(__WXPALMOS__) && !defined( __VMS )
+            || errno != EOVERFLOW
+#endif
+            )
         {
             // ok, there was enough space
             break;