--- a/src/port/sprompt.c	2012-02-24 02:53:36.000000000 +0400
+++ b/src/port/sprompt.c	2012-03-20 23:34:22.181979200 +0400
@@ -41,6 +41,7 @@
 	char	   *destination;
 	FILE	   *termin,
 			   *termout;
+	char	   *_prompt;
 
 #ifdef HAVE_TERMIOS_H
 	struct termios t_orig,
@@ -49,6 +50,7 @@
 #ifdef WIN32
 	HANDLE		t = NULL;
 	LPDWORD		t_orig = NULL;
+	char	   *oem_prompt = NULL;
 #endif
 #endif
 
@@ -104,7 +106,20 @@
 
 	if (prompt)
 	{
-		fputs(_(prompt), termout);
+		_prompt = _(prompt);
+#ifdef WIN32
+		if ((termout != stderr) && (termout != stdout))
+		{
+			oem_prompt = (char*) malloc(strlen(_prompt) + 1);
+			CharToOemBuff(_prompt, oem_prompt, strlen(_prompt) + 1);
+			_prompt = oem_prompt;
+		}
+#endif
+		fputs(_prompt, termout);
+#ifdef WIN32
+		if (oem_prompt)
+			free(oem_prompt);
+#endif
 		fflush(termout);
 	}
 
@@ -130,6 +145,13 @@
 		/* remove trailing newline */
 		destination[length - 1] = '\0';
 
+#ifdef WIN32
+	if (termin != stdin)
+	{
+		OemToCharBuff(destination, destination, strlen(destination) + 1);
+	}
+#endif
+
 #ifdef HAVE_TERMIOS_H
 	if (!echo)
 	{
