From 668a958fa2a1c850eb6cf9a70dc1ba826852c4ca Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 24 Apr 2006 16:08:39 +0000 Subject: [PATCH] add encoding check --- stepmania/src/smpackage/LanguagesDlg.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/stepmania/src/smpackage/LanguagesDlg.cpp b/stepmania/src/smpackage/LanguagesDlg.cpp index 61e1482a57..9336100917 100644 --- a/stepmania/src/smpackage/LanguagesDlg.cpp +++ b/stepmania/src/smpackage/LanguagesDlg.cpp @@ -540,6 +540,30 @@ void LanguagesDlg::OnBnClickedCheckLanguage() } } + { + FOREACH_CONST_Child( &ini2, key ) + { + FOREACH_CONST_Attr( key, value ) + { + const RString &sSection = key->m_sName; + const RString &sID = value->first; + const RString &sCurrentLanguage = value->second; + if( utf8_is_valid(sCurrentLanguage) ) + continue; + + /* The text isn't valid UTF-8. We don't know what encoding it is; guess that it's + * ISO-8859-1 and convert it so it'll display correctly and can be pasted into + * the file. Don't include the original text: if we include multiple encodings + * in the resulting text file, editors won't understand the encoding of the + * file and will pick one arbitrarily. */ + file.PutLine( ssprintf("Incorrect encoding in section [%s]:", sSection.c_str()) ); + wstring wsConverted = ConvertCodepageToWString( sCurrentLanguage, 1252 ); + RString sConverted = WStringToRString( wsConverted ); + file.PutLine( ssprintf("%s=%s", sID.c_str(), sConverted.c_str()) ); + } + } + } + { FOREACH_CONST_Child( &ini1, key ) {