Merge pull request #990 from david-puglielli/issue-909-fix

Issue 909 fix
This commit is contained in:
David Puglielli 2019-05-13 12:18:51 -07:00 committed by GitHub
commit e152459699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -280,9 +280,23 @@ bool EncodingConverter::Initialize()
using namespace std;
SystemLocale::SystemLocale( const char * localeName )
: m_pLocale( new std::locale(localeName) )
, m_uAnsiCP(CP_UTF8)
: m_uAnsiCP(CP_UTF8)
, m_pLocale(NULL)
{
const char* DEFAULT_LOCALE = "en_US.UTF-8";
try {
m_pLocale = new std::locale(localeName);
}
catch(const std::exception& e) {
localeName = DEFAULT_LOCALE;
}
if(!m_pLocale) {
m_pLocale = new std::locale(localeName);
}
// Mapping from locale charset to codepage
struct LocaleCP
{
const char* localeName;
@ -331,8 +345,7 @@ const SystemLocale & SystemLocale::Singleton()
#if !defined(__GNUC__) || defined(NO_THREADSAFE_STATICS)
#error "Relying on GCC's threadsafe initialization of local statics."
#endif
// get locale from environment and set as default
static const SystemLocale s_Default(setlocale(LC_ALL, NULL));
static const SystemLocale s_Default(setlocale(LC_CTYPE, NULL));
return s_Default;
}