From 5e12096e4b912d65d7b3b4b9c70f7dbeaf84392c Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 2 Aug 2016 12:42:28 +0200 Subject: [PATCH] Only use UTF-8 locales. --- src/modules/locale/LocalePage.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index abeabca89..d2e86fc02 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -281,6 +281,22 @@ LocalePage::init( const QString& initialRegion, m_localeGenLines.append( lineString ); } } + + if ( m_localeGenLines.isEmpty() ) + { + cDebug() << "WARNING: cannot get list of supported locales from anywhere."; + return; // something went wrong and there's nothing we can do about it. + } + + // Assuming we have a list of supported locales, we usually only want UTF-8 ones + // because it's not 1995. + for ( auto it = m_localeGenLines.begin(); it != m_localeGenLines.end(); ) + { + if ( !it->contains( "UTF-8", Qt::CaseInsensitive ) ) + it = m_localeGenLines.erase( it ); + else + ++it; + } }