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

Some users reported problems with subtitles encoding on Win32.

Probably a setlocale() breakage. Use GetACP() instead.
parent 4db8257a
......@@ -283,7 +283,7 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
char buf[2 + 10 + 1];
/* Woe32 has a function returning the locale's codepage as a number. */
sprintf( buf, "CP%u", GetACP() );
snprintf( buf, sizeof( buf ), "CP%u", GetACP() );
psz_codeset = buf;
#elif defined OS2
......@@ -312,7 +312,7 @@ vlc_bool_t vlc_current_charset( char **psz_charset )
psz_codeset = "";
else
{
sprintf( buf, "CP%u", cp[0] );
snprintf( buf, sizeof( buf ), "CP%u", cp[0] );
psz_codeset = buf;
}
}
......@@ -564,11 +564,12 @@ const char *FindFallbackEncoding( const char *locale )
*/
const char *GetFallbackEncoding( void )
{
#ifndef WIN32
const char *psz_lang = NULL;
/* Some systems (like Darwin, SunOS 4 or DJGPP) have only the C locale.
* Therefore we don't use setlocale here; it would return "C". */
# if HAVE_SETLOCALE && !__APPLE__
# if defined (HAVE_SETLOCALE) && !defined ( __APPLE__)
psz_lang = setlocale( LC_ALL, NULL );
# endif
if( psz_lang == NULL || psz_lang[0] == '\0' )
......@@ -583,6 +584,17 @@ const char *GetFallbackEncoding( void )
}
return FindFallbackEncoding( psz_lang );
#else
/*
* This should be thread-safe given GetACP() should always return
* the same result.
*/
static char buf[2 + 10 + 1] = "";
if( buf[0] == 0 )
snprintf( buf, sizeof( buf ), "CP%u", GetACP() );
return buf;
#endif
}
/**
......
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