+extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
+ const wxChar *format, va_list argptr)
+{
+#if wxUSE_UNICODE
+ // FIXME should use wvsnprintf() or whatever if it's available
+ wxString s;
+ int iLen = s.PrintfV(format, argptr);
+ if ( iLen != -1 )
+ {
+ wxStrncpy(buf, s.c_str(), len);
+ buf[len-1] = wxT('\0');
+ }
+
+ return iLen;
+#else // ANSI
+ // vsnprintf() will not terminate the string with '\0' if there is not
+ // enough place, but we want the string to always be NUL terminated
+ int rc = wxVsnprintfA(buf, len - 1, format, argptr);
+ if ( rc == -1 )
+ {
+ buf[len] = 0;
+ }
+
+ return rc;
+#endif // Unicode/ANSI
+}
+
+extern int WXDLLEXPORT wxSnprintf(wxChar *buf, size_t len,
+ const wxChar *format, ...)
+{
+ va_list argptr;
+ va_start(argptr, format);
+
+ int iLen = wxVsnprintf(buf, len, format, argptr);
+
+ va_end(argptr);
+
+ return iLen;
+}
+