- // buffer to avoid dynamic memory allocation each time for small strings
- static char szScratch[1024];
- size_t lenCur = 0;
+ // buffer to avoid dynamic memory allocation each time for small strings;
+ // note that this buffer is used only to hold results of number formatting,
+ // %s directly writes user's string in buf, without using szScratch
+#define wxSCRATCH_BUFFER_SIZE 512
+
+ wxChar szScratch[wxSCRATCH_BUFFER_SIZE];
+ size_t lenScratch = 0, lenCur = 0;
+
+#if wxUSE_UNICODE
+#define system_sprintf(buff, flags, data) ::swprintf(buff, wxSCRATCH_BUFFER_SIZE, flags, data)
+#else
+#define system_sprintf ::sprintf
+#endif