Skip to content

Commit

Permalink
Merge pull request #990 from david-puglielli/issue-909-fix
Browse files Browse the repository at this point in the history
Issue 909 fix
  • Loading branch information
david-puglielli authored May 13, 2019
2 parents 3b6b076 + 1aa8dea commit e152459
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions source/shared/localizationimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit e152459

Please sign in to comment.