add iso-8859-1

separate utf-8
This commit is contained in:
Glenn Maynard
2003-06-30 08:39:18 +00:00
parent 3086ba4ea2
commit 40abed2aca
+15 -3
View File
@@ -29,6 +29,7 @@ static bool CodePageConvert(CString &txt, int cp)
return true; return true;
} }
static bool AttemptEnglishConversion( CString &txt ) { return CodePageConvert( txt, 1252 ); }
static bool AttemptKoreanConversion( CString &txt ) { return CodePageConvert( txt, 949 ); } static bool AttemptKoreanConversion( CString &txt ) { return CodePageConvert( txt, 949 ); }
static bool AttemptJapaneseConversion( CString &txt ) { return CodePageConvert( txt, 932 ); } static bool AttemptJapaneseConversion( CString &txt ) { return CodePageConvert( txt, 932 ); }
@@ -40,6 +41,7 @@ TODO
#else #else
/* No converters are available, so all fail--we only accept UTF-8. */ /* No converters are available, so all fail--we only accept UTF-8. */
static bool AttemptEnglishConversion( CString &txt ) { return false; }
static bool AttemptKoreanConversion( CString &txt ) { return false; } static bool AttemptKoreanConversion( CString &txt ) { return false; }
static bool AttemptJapaneseConversion( CString &txt ) { return false; } static bool AttemptJapaneseConversion( CString &txt ) { return false; }
@@ -50,12 +52,22 @@ bool ConvertString(CString &str, const CString &encodings)
CStringArray lst; CStringArray lst;
split(encodings, ",", lst); split(encodings, ",", lst);
for(unsigned i = 0; i < lst.size(); ++i)
{
if( lst[i] == "utf-8" )
{
/* Is the string already valid utf-8? */ /* Is the string already valid utf-8? */
if( utf8_is_valid(str) ) if( utf8_is_valid(str) )
return true; return true;
continue;
for(unsigned i = 0; i < lst.size(); ++i) }
if( lst[i] == "english" )
{ {
if(AttemptEnglishConversion(str))
return true;
continue;
}
if( lst[i] == "japanese" ) if( lst[i] == "japanese" )
{ {
if(AttemptJapaneseConversion(str)) if(AttemptJapaneseConversion(str))
@@ -70,7 +82,7 @@ bool ConvertString(CString &str, const CString &encodings)
continue; continue;
} }
RageException::Throw( "Unexpected conversion string \"%s\" (string \"%s\"", RageException::Throw( "Unexpected conversion string \"%s\" (string \"%s\")",
lst[i].c_str(), str.c_str() ); lst[i].c_str(), str.c_str() );
} }