[MPlayer-dev-eng] [PATCH] Filename double-conversion
Zuxy Meng
zuxy.meng at gmail.com
Thu Nov 16 07:44:41 CET 2006
Hi,
2006/11/16, Bernd Ernesti <mplayer-dev-eng at lists.veego.de>:
> Not directly in <limits.h> but with another include file which is
> included by limits.h. So thats fine too.
That's OK! New patch attached!
> #define MSG_CHARSET "UTF-8"
>
> Sorry, I didn't mean that it doesn't work. I see the correct filename too
> even without this patch when i use a kterm.
Good news; at least it didn't cause regression:-) BTW: what's your
locale anyway?
--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c ???????? 20426??
+++ mplayer.c ????????????
@@ -986,7 +987,8 @@
#else
if(!subd && !silent)
#endif
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub, filename);
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub,
+ filename_recode(filename));
#ifdef USE_ASS
if (!asst && !subd) return;
@@ -996,9 +998,11 @@
#endif
set_of_subtitles[set_of_sub_size] = subd;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_ID=%d\n", set_of_sub_size);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n", filename);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",
+ filename_recode(filename));
++set_of_sub_size;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, set_of_sub_size, filename);
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, set_of_sub_size,
+ filename_recode(filename));
}
// FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken.
@@ -3084,7 +3088,8 @@
#ifdef HAVE_BITMAP_FONT
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
- if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+ if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,
+ filename_recode(font_name));
} else {
// try default:
vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1);
@@ -3332,7 +3337,9 @@
}
//---------------------------------------------------------------------------
- if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
+ if(filename)
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing,
+ filename_recode(filename));
if (edl_filename) {
if (edl_records) free_edl(edl_records);
@@ -3343,7 +3350,7 @@
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
{
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,
- edl_output_filename);
+ filename_recode(edl_output_filename));
}
}
@@ -3353,7 +3360,8 @@
if (vobsub_name){
vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec);
if(vo_vobsub==NULL)
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name);
+ mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,
+ filename_recode(vobsub_name));
}else if(sub_auto && filename && (strlen(filename)>=5)){
/* try to autodetect vobsub from movie filename ::atmos */
char *buf = malloc((strlen(filename)-3)),*psub;
@@ -3420,7 +3428,8 @@
play_tree_t* entry;
// Handle playlist
current_module="handle_playlist";
- mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename);
+ mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",
+ filename_recode(filename));
entry = parse_playtree(stream,0);
eof=playtree_add_playlist(entry);
goto goto_next_file;
@@ -3500,7 +3509,8 @@
{
char *temp, *bname;
- mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",playlist_entry);
+ mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",
+ filename_recode(playlist_entry));
bname=mp_basename(playlist_entry);
if ((strlen(bname)>10) && !strncmp(bname,"qt",2) && !strncmp(bname+3,"gateQT",6))
@@ -3796,7 +3806,8 @@
}
}
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n", filename);
+ mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n",
+ filename_recode(filename));
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_DEMUXER=%s\n", demuxer->desc->name);
if (sh_video) {
/* Assume FOURCC if all bytes >= 0x20 (' ') */
@@ -4993,7 +5004,8 @@
if (v < 0) {
for (v = 0; v < set_of_sub_size; ++v) {
subd = set_of_subtitles[v];
- mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename);
+ mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
+ filename_recode(subd->filename));
sub_free(subd);
set_of_subtitles[v] = NULL;
}
@@ -5010,7 +5022,8 @@
}
else if (v < set_of_sub_size) {
subd = set_of_subtitles[v];
- mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename);
+ mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
+ filename_recode(subd->filename));
sub_free(subd);
if (set_of_sub_pos == v) {
global_sub_pos = -2;
Index: mp_msg.h
===================================================================
--- mp_msg.h ???????? 20426??
+++ mp_msg.h ????????????
@@ -14,6 +14,7 @@
#endif
#ifdef USE_ICONV
#include <iconv.h>
+#include <limits.h>
#endif
#if defined(FOR_MENCODER) || defined(CODECS2HTML)
@@ -128,6 +128,7 @@
# endif
#endif
+const char* filename_recode(const char* filename);
#endif
#endif
Index: mp_msg.c
===================================================================
--- mp_msg.c ???????? 20547??
+++ mp_msg.c ????????????
@@ -38,6 +42,33 @@
static iconv_t msgiconv;
#endif
+const char* filename_recode(const char* filename)
+{
+#if !defined(USE_ICONV) || !defined(MSG_CHARSET)
+ return filename;
+#else
+ static iconv_t inv_msgiconv = (iconv_t)(-1);
+ static char recoded_filename[PATH_MAX];
+ size_t filename_len, max_path;
+ char* precoded_filename;
+ if (!strcasecmp(mp_msg_charset, MSG_CHARSET) ||
+ !strcasecmp(mp_msg_charset, "noconv"))
+ return filename;
+ if (inv_msgiconv == (iconv_t)(-1)) {
+ inv_msgiconv = iconv_open(MSG_CHARSET, mp_msg_charset);
+ if (inv_msgiconv == (iconv_t)(-1))
+ return filename;
+ }
+ filename_len = strlen(filename);
+ max_path = PATH_MAX - 1;
+ precoded_filename = recoded_filename;
+ iconv(inv_msgiconv, &filename, &filename_len,
+ &precoded_filename, &max_path);
+ *precoded_filename = '\0';
+ return recoded_filename;
+#endif
+}
+
void mp_msg_init(void){
int i;
char *env = getenv("MPLAYER_VERBOSE");
More information about the MPlayer-dev-eng
mailing list