Commit 32008664 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Convert to local encoding before printing on console (closes #556)

parent cf8c7b4e
...@@ -2080,13 +2080,13 @@ static void Help( vlc_t *p_this, char const *psz_help_name ) ...@@ -2080,13 +2080,13 @@ static void Help( vlc_t *p_this, char const *psz_help_name )
if( psz_help_name && !strcmp( psz_help_name, "help" ) ) if( psz_help_name && !strcmp( psz_help_name, "help" ) )
{ {
fprintf( stdout, VLC_USAGE, p_this->psz_object_name ); utf8_fprintf( stdout, VLC_USAGE, p_this->psz_object_name );
Usage( p_this, "help" ); Usage( p_this, "help" );
Usage( p_this, "main" ); Usage( p_this, "main" );
} }
else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) ) else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) )
{ {
fprintf( stdout, VLC_USAGE, p_this->psz_object_name ); utf8_fprintf( stdout, VLC_USAGE, p_this->psz_object_name );
Usage( p_this, NULL ); Usage( p_this, NULL );
} }
else if( psz_help_name ) else if( psz_help_name )
...@@ -2177,7 +2177,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2177,7 +2177,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
/* Print name of module */ /* Print name of module */
if( strcmp( "main", p_parser->psz_object_name ) ) if( strcmp( "main", p_parser->psz_object_name ) )
fprintf( stdout, "\n %s\n", p_parser->psz_longname ); utf8_fprintf( stdout, "\n %s\n", p_parser->psz_longname );
b_help_module = !strcmp( "help", p_parser->psz_object_name ); b_help_module = !strcmp( "help", p_parser->psz_object_name );
...@@ -2207,7 +2207,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2207,7 +2207,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
case CONFIG_HINT_CATEGORY: case CONFIG_HINT_CATEGORY:
case CONFIG_HINT_USAGE: case CONFIG_HINT_USAGE:
if( !strcmp( "main", p_parser->psz_object_name ) ) if( !strcmp( "main", p_parser->psz_object_name ) )
fprintf( stdout, "\n %s\n", p_item->psz_text ); utf8_fprintf( stdout, "\n %s\n", p_item->psz_text );
break; break;
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
...@@ -2301,13 +2301,13 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2301,13 +2301,13 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
if( p_item->i_type == CONFIG_ITEM_BOOL && !b_help_module ) if( p_item->i_type == CONFIG_ITEM_BOOL && !b_help_module )
{ {
fprintf( stdout, psz_format, psz_short, p_item->psz_name, utf8_fprintf( stdout, psz_format, psz_short, p_item->psz_name,
psz_prefix, p_item->psz_name, psz_bra, psz_type, psz_prefix, p_item->psz_name, psz_bra, psz_type,
psz_ket, psz_spaces ); psz_ket, psz_spaces );
} }
else else
{ {
fprintf( stdout, psz_format, psz_short, p_item->psz_name, utf8_fprintf( stdout, psz_format, psz_short, p_item->psz_name,
"", "", psz_bra, psz_type, psz_ket, psz_spaces ); "", "", psz_bra, psz_type, psz_ket, psz_spaces );
} }
...@@ -2327,7 +2327,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2327,7 +2327,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
/* If the remaining text fits in a line, print it. */ /* If the remaining text fits in a line, print it. */
if( i_end <= (size_t)i_width ) if( i_end <= (size_t)i_width )
{ {
fprintf( stdout, "%s\n", psz_text ); utf8_fprintf( stdout, "%s\n", psz_text );
break; break;
} }
...@@ -2355,14 +2355,14 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2355,14 +2355,14 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
{ {
char c = psz_text[i_width]; char c = psz_text[i_width];
psz_text[i_width] = '\0'; psz_text[i_width] = '\0';
fprintf( stdout, "%s\n%s", psz_text, psz_spaces ); utf8_fprintf( stdout, "%s\n%s", psz_text, psz_spaces );
psz_text += i_width; psz_text += i_width;
psz_text[0] = c; psz_text[0] = c;
} }
else else
{ {
psz_word[-1] = '\0'; psz_word[-1] = '\0';
fprintf( stdout, "%s\n%s", psz_text, psz_spaces ); utf8_fprintf( stdout, "%s\n%s", psz_text, psz_spaces );
psz_text = psz_word; psz_text = psz_word;
} }
} }
...@@ -2372,7 +2372,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name ) ...@@ -2372,7 +2372,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
sprintf( psz_buffer, "%s%s", p_item->psz_longtext, psz_suf ); sprintf( psz_buffer, "%s%s", p_item->psz_longtext, psz_suf );
b_description = VLC_FALSE; b_description = VLC_FALSE;
psz_spaces = psz_spaces_longtext; psz_spaces = psz_spaces_longtext;
fprintf( stdout, "%s", psz_spaces ); utf8_fprintf( stdout, "%s", psz_spaces );
goto description; goto description;
} }
} }
...@@ -2417,7 +2417,7 @@ static void ListModules( vlc_t *p_this ) ...@@ -2417,7 +2417,7 @@ static void ListModules( vlc_t *p_this )
if( i < 0 ) i = 0; if( i < 0 ) i = 0;
psz_spaces[i] = 0; psz_spaces[i] = 0;
fprintf( stdout, " %s%s %s\n", p_parser->psz_object_name, utf8_fprintf( stdout, " %s%s %s\n", p_parser->psz_object_name,
psz_spaces, p_parser->psz_longname ); psz_spaces, p_parser->psz_longname );
psz_spaces[i] = ' '; psz_spaces[i] = ' ';
...@@ -2441,14 +2441,14 @@ static void Version( void ) ...@@ -2441,14 +2441,14 @@ static void Version( void )
ShowConsole( VLC_TRUE ); ShowConsole( VLC_TRUE );
#endif #endif
fprintf( stdout, _("VLC version %s\n"), VLC_Version() ); utf8_fprintf( stdout, _("VLC version %s\n"), VLC_Version() );
fprintf( stdout, _("Compiled by %s@%s.%s\n"), utf8_fprintf( stdout, _("Compiled by %s@%s.%s\n"),
VLC_CompileBy(), VLC_CompileHost(), VLC_CompileDomain() ); VLC_CompileBy(), VLC_CompileHost(), VLC_CompileDomain() );
fprintf( stdout, _("Compiler: %s\n"), VLC_Compiler() ); utf8_fprintf( stdout, _("Compiler: %s\n"), VLC_Compiler() );
if( strcmp( VLC_Changeset(), "exported" ) ) if( strcmp( VLC_Changeset(), "exported" ) )
fprintf( stdout, _("Based upon svn changeset [%s]\n"), utf8_fprintf( stdout, _("Based upon svn changeset [%s]\n"),
VLC_Changeset() ); VLC_Changeset() );
fprintf( stdout, LICENSE_MSG ); utf8_fprintf( stdout, LICENSE_MSG );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ #ifdef WIN32 /* Pause the console because it's destroyed when we exit */
PauseConsole(); PauseConsole();
...@@ -2477,7 +2477,7 @@ static void ShowConsole( vlc_bool_t b_dofile ) ...@@ -2477,7 +2477,7 @@ static void ShowConsole( vlc_bool_t b_dofile )
{ {
fclose( f_help ); fclose( f_help );
freopen( "vlc-help.txt", "wt", stdout ); freopen( "vlc-help.txt", "wt", stdout );
fprintf( stderr, _("\nDumped content to vlc-help.txt file.\n") ); utf8_fprintf( stderr, _("\nDumped content to vlc-help.txt file.\n") );
} }
else freopen( "CONOUT$", "w", stdout ); else freopen( "CONOUT$", "w", stdout );
...@@ -2498,7 +2498,7 @@ static void PauseConsole( void ) ...@@ -2498,7 +2498,7 @@ static void PauseConsole( void )
if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */ if( getenv( "PWD" ) && getenv( "PS1" ) ) return; /* cygwin shell */
fprintf( stderr, _("\nPress the RETURN key to continue...\n") ); utf8_fprintf( stderr, _("\nPress the RETURN key to continue...\n") );
getchar(); getchar();
fclose( stdout ); fclose( stdout );
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#endif #endif
#include "vlc_interface.h" #include "vlc_interface.h"
#include "charset.h"
/***************************************************************************** /*****************************************************************************
* Local macros * Local macros
...@@ -333,9 +334,10 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type, ...@@ -333,9 +334,10 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue_id, int i_type,
fprintf( stderr, "main warning: can't store message (%s): ", fprintf( stderr, "main warning: can't store message (%s): ",
strerror(errno) ); strerror(errno) );
vlc_va_copy( args, _args ); vlc_va_copy( args, _args );
/* We should use utf8_vfprintf - but it calls malloc()... */
vfprintf( stderr, psz_format, args ); vfprintf( stderr, psz_format, args );
va_end( args ); va_end( args );
fprintf( stderr, "\n" ); fputs( "\n", stderr );
return; return;
} }
...@@ -596,7 +598,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item ) ...@@ -596,7 +598,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
{ {
if( p_item->psz_header ) if( p_item->psz_header )
{ {
fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s %s%s: %s%s" GRAY utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s %s%s: %s%s" GRAY
"\n", "\n",
p_item->i_object_id, p_item->psz_header, p_item->i_object_id, p_item->psz_header,
p_item->psz_module, psz_object, p_item->psz_module, psz_object,
...@@ -605,7 +607,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item ) ...@@ -605,7 +607,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
} }
else else
{ {
fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n", utf8_fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n",
p_item->i_object_id, p_item->psz_module, psz_object, p_item->i_object_id, p_item->psz_module, psz_object,
ppsz_type[i_type], ppsz_color[i_type], ppsz_type[i_type], ppsz_color[i_type],
p_item->psz_msg ); p_item->psz_msg );
...@@ -615,13 +617,13 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item ) ...@@ -615,13 +617,13 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
{ {
if( p_item->psz_header ) if( p_item->psz_header )
{ {
fprintf( stderr, "[%.8i] %s %s %s%s: %s\n", p_item->i_object_id, utf8_fprintf( stderr, "[%.8i] %s %s %s%s: %s\n", p_item->i_object_id,
p_item->psz_header, p_item->psz_module, p_item->psz_header, p_item->psz_module,
psz_object, ppsz_type[i_type], p_item->psz_msg ); psz_object, ppsz_type[i_type], p_item->psz_msg );
} }
else else
{ {
fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id, utf8_fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id,
p_item->psz_module, psz_object, ppsz_type[i_type], p_item->psz_module, psz_object, ppsz_type[i_type],
p_item->psz_msg ); p_item->psz_msg );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment