--- mplayer_base/cfg-common.h	2008-04-18 02:12:57.000000000 +0400
+++ mplayer/cfg-common.h	2008-04-19 19:41:42.000000000 +0400
@@ -35,6 +35,9 @@
 extern int network_ipv4_only_proxy;
 extern int reuse_socket;
 
+/* defined in stream_ftp.c */
+extern char *ftp_charset;
+
 extern int dvd_speed; /* stream/stream_dvd.c */
 
 extern float a52_drc_level;
--- mplayer_base/cfg-common-opts.h	2008-04-18 02:12:57.000000000 +0400
+++ mplayer/cfg-common-opts.h	2008-04-19 19:44:41.000000000 +0400
@@ -63,6 +63,9 @@
 	{"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, NULL},	
 	{"reuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
 	{"noreuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
+#ifdef USE_ICONV
+	{"ftp-charset", &ftp_charset, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#endif /* USE_ICONV */
 #ifdef HAVE_AF_INET6
 	{"prefer-ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 #else
--- mplayer_base/stream/stream_ftp.c	2008-01-27 14:17:07.000000000 +0300
+++ mplayer/stream/stream_ftp.c	2008-04-19 21:06:38.000000000 +0400
@@ -23,6 +23,20 @@
 #include "m_struct.h"
 #include "tcp.h"
 
+#ifdef USE_ICONV
+#include <iconv.h>
+#include <string.h>
+
+//server charset, to set from command line
+char *ftp_charset=NULL;
+//we need to get local charset
+extern char* get_term_charset(void);
+
+iconv_t iconv_filename = (iconv_t)(-1);
+char *iconv_buf;
+size_t iconv_bufsize = 0;
+#endif /* USE_ICONV */
+
 static struct stream_priv_s {
   char* user;
   char* pass;
@@ -431,6 +445,28 @@
     return STREAM_ERROR;
   }
 
+#ifdef USE_ICONV
+  //recode filename if needed
+  if (ftp_charset) {
+    size_t len;
+
+    mp_msg(MSGT_OPEN, MSGL_V, "[ftp] recoding filename %s from %s to %s\n",
+            p->filename, get_term_charset(), ftp_charset);
+    
+    if (!iconv_bufsize) {
+      iconv_bufsize = BUFSIZE;
+      iconv_buf = malloc(iconv_bufsize);
+    }
+
+    mp_recode_to(&iconv_filename, p->filename, 
+            ftp_charset, get_term_charset(),
+            &iconv_buf, &iconv_bufsize);
+    len = strlen(iconv_buf) + 1;
+    p->filename = realloc(p->filename, len);
+    memcpy(p->filename, iconv_buf, len);
+  }
+#endif /* USE_ICONV */
+
   // Get the filesize
   snprintf(str,255,"SIZE %s",p->filename);
   resp = FtpSendCmd(str,p,rsp_txt);
--- mplayer_base/DOCS/man/en/mplayer.1	2008-04-19 01:52:35.000000000 +0400
+++ mplayer/DOCS/man/en/mplayer.1	2008-04-19 07:46:09.000000000 +0400
@@ -1461,6 +1461,14 @@
 Play/\:convert only first <number> frames, then quit.
 .
 .TP
+.B \-ftp\-charset <codepage> (iconv only)
+Specify charset of the FTP server to connect to. You can specify it
+in any format understandable by
+.BR iconv (3)
+program. This is useful when your locale differs from the server's 
+one.
+.
+.TP
 .B \-hr\-mp3\-seek (MP3 only)
 Hi-res MP3 seeking.
 Enabled when playing from an external MP3 file, as we need to seek
