+int
+win32_fputs(const char *string, FILE *stream)
+{
+ /* we use _cwprintf (console printf)
+ so we can be sure that unicode support works on win32.
+ this works under nt and 98 (95 and me not tested)
+ */
+
+ if (p_MultiByteToWideChar && (stream == stdout) && p_cwprintf) {
+ WCHAR szBuf[MAX_PATH_UNICODE];
+ UTF8_2_wchar(szBuf, string, MAX_PATH_UNICODE);
+ return p_cwprintf (szBuf);
+ }
+
+ return fputs(string, stream);
+}
+
+char*
+win32_cgets (char* buffer, int len)
+{
+ /* we use console gets / getws to be able to read unicode
+ from the win32 console */
+
+ /* nt and unicode conversion */
+ if ((g_platform_id == VER_PLATFORM_WIN32_NT) && p_WideCharToMultiByte && p_cgetws) {
+ WCHAR szBuf[260];
+ szBuf[0] = min (255, len); /* max len, must be smaller than buffer */
+ if (p_cgetws(szBuf) && wchar_2_UTF8(buffer, &szBuf[2], len))
+ return buffer;
+ }
+
+ /* win 9x and unicode conversion */
+ if ((g_platform_id == VER_PLATFORM_WIN32_WINDOWS) && p_WideCharToMultiByte && p_MultiByteToWideChar) {
+ char szBuf[260];
+ szBuf[0] = min(255, len); /* max len, must be smaller than buffer */
+ if (_cgets(szBuf)) {
+ WCHAR wszBuf[260];
+ p_MultiByteToWideChar(CP_OEMCP, 0, &szBuf[2], -1, wszBuf,260);
+
+ if (wchar_2_UTF8(buffer, wszBuf, len))
+ return buffer;
+ }
+ }
+
+ /* fallback */
+ if (fgets(buffer, len, stdin))
+ return buffer;
+ else
+ return NULL;
+}
+
+int
+win32_unlink(const char *filename)
+{
+ int nRetCode;
+ if (p_wunlink) {
+ WCHAR szBuf[MAX_PATH_UNICODE];
+ UTF8_2_wchar(szBuf, filename, MAX_PATH_UNICODE);
+ nRetCode = _wunlink(szBuf);
+ } else {
+ nRetCode = _unlink(filename);
+ }
+ return nRetCode;
+}
+
+