--- mplayer/cfg-common.h.orig	2008-04-11 20:49:58.000000000 +0400
+++ mplayer/cfg-common.h	2008-04-12 00:15:34.000000000 +0400
@@ -33,6 +33,11 @@
 extern int network_ipv4_only_proxy;
 extern int reuse_socket;
 
+/* defined in stream_ftp.c */
+#ifdef USE_ICONV
+extern char *ftp_charset;
+#endif /* USE_ICONV */
+
 extern int dvd_speed; /* stream/stream_dvd.c */
 
 extern float a52_drc_level;
--- mplayer/cfg-common-opts.h.orig	2008-04-11 20:54:09.000000000 +0400
+++ mplayer/cfg-common-opts.h	2008-04-11 23:39:33.000000000 +0400
@@ -61,6 +61,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/stream/stream_ftp.c.orig	2008-04-11 20:49:59.000000000 +0400
+++ mplayer/stream/stream_ftp.c	2008-04-12 04:27:05.000000000 +0400
@@ -23,6 +23,16 @@
 #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);
+#endif /* USE_ICONV */
+
 static struct stream_priv_s {
   char* user;
   char* pass;
@@ -431,6 +441,24 @@
     return STREAM_ERROR;
   }
 
+#ifdef USE_ICONV
+  //recode filename if needed
+  if (ftp_charset) {
+    mp_msg(MSGT_OPEN, MSGL_V, "[ftp] recoding filename %s from %s to %s\n",
+            p->filename, get_term_charset(), ftp_charset);
+    
+    iconv_t iconv_filename = (iconv_t)(-1);
+    /* There is no guarantee that filename_recode_common wouldn't
+     * be called during playback. Thus buffer must be copied to
+     * p->filename with appropriate memory reallocation. */
+    char *buf = filename_recode_common(iconv_filename, 
+            p->filename, ftp_charset, get_term_charset());
+    size_t len = strlen(buf) + 1;
+    p->filename = realloc(p->filename, len);
+    memcpy(p->filename, buf, len);
+  }
+#endif /* USE_ICONV */
+
   // Get the filesize
   snprintf(str,255,"SIZE %s",p->filename);
   resp = FtpSendCmd(str,p,rsp_txt);
