X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Ftext%2Fwincp.c;h=97dfc6158a99b570c75ab67da038214678b816e6;hb=84091c6692d4e22e6082ecf692c4df6e9e292b2f;hp=d0447e19a22dd1c2ba60611ee3ba6d0023e70e6a;hpb=9709cd067802994f8d40040f31c8527687c7c479;p=vlc diff --git a/src/text/wincp.c b/src/text/wincp.c index d0447e19a2..97dfc6158a 100644 --- a/src/text/wincp.c +++ b/src/text/wincp.c @@ -22,10 +22,11 @@ /*** We need your help to complete this file!! Look for FIXME ***/ -#include -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #ifndef WIN32 # include @@ -58,7 +59,7 @@ static const char *FindFallbackEncoding (const char *locale) { if ((locale == NULL) || (strlen (locale) < 2) || !strcasecmp (locale, "POSIX")) - return "ASCII"; + return "CP1252"; /* Yeah, this is totally western-biased */ /*** The ISO-8859 series (anything but Asia) ***/ @@ -100,7 +101,7 @@ static const char *FindFallbackEncoding (const char *locale) /* Hebrew (ISO-8859-8) */ if (!locale_match ("he" "iw" "yi", locale)) - return "CP1255"; // Compatible Microsoft superset + return "ISO-8859-8"; // CP1255 is reportedly screwed up /* Latin-5 Turkish (ISO-8859-9) */ if (!locale_match ("tr" "ku", locale)) @@ -194,28 +195,33 @@ static 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 defined (HAVE_SETLOCALE) && !defined ( __APPLE__) - psz_lang = setlocale (LC_ALL, NULL); -# endif - if (psz_lang == NULL) + const char *psz_lang; + + psz_lang = getenv ("LC_ALL"); + if ((psz_lang == NULL) || !*psz_lang) { - psz_lang = getenv ("LC_ALL"); + psz_lang = getenv ("LC_CTYPE"); if ((psz_lang == NULL) || !*psz_lang) - { - psz_lang = getenv ("LC_CTYPE"); - if ((psz_lang == NULL)) - psz_lang = getenv ("LANG"); - } + psz_lang = getenv ("LANG"); } return FindFallbackEncoding (psz_lang); #else + static char buf[16] = ""; + if (buf[0] == 0) - snprintf (buf, sizeof (buf), "CP%u", GetACP ()); + { + int cp = GetACP (); + + switch (cp) + { + case 1255: // Hebrew, CP1255 screws up somewhat + strcpy (buf, "ISO-8859-8"); + break; + default: + snprintf (buf, sizeof (buf), "CP%u", cp); + } + } return buf; #endif }