X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4dc55027531c688d9eebb88485b4789a143aa2cb..226c11c0767b3dfded410b8c8be8cf0d9444d136:/src/common/fmapbase.cpp diff --git a/src/common/fmapbase.cpp b/src/common/fmapbase.cpp index b49754d7f9..b7107408bd 100644 --- a/src/common/fmapbase.cpp +++ b/src/common/fmapbase.cpp @@ -72,6 +72,7 @@ static wxFontEncoding gs_encodings[] = wxFONTENCODING_ISO8859_14, wxFONTENCODING_ISO8859_15, wxFONTENCODING_KOI8, + wxFONTENCODING_KOI8_U, wxFONTENCODING_CP932, wxFONTENCODING_CP936, wxFONTENCODING_CP949, @@ -87,6 +88,12 @@ static wxFontEncoding gs_encodings[] = wxFONTENCODING_CP437, wxFONTENCODING_UTF7, wxFONTENCODING_UTF8, + wxFONTENCODING_UTF16, + wxFONTENCODING_UTF16BE, + wxFONTENCODING_UTF16LE, + wxFONTENCODING_UTF32, + wxFONTENCODING_UTF32BE, + wxFONTENCODING_UTF32LE, wxFONTENCODING_EUC_JP, }; @@ -109,6 +116,7 @@ static const wxChar* gs_encodingDescs[] = wxTRANSLATE( "Celtic (ISO-8859-14)" ), wxTRANSLATE( "Western European with Euro (ISO-8859-15)" ), wxTRANSLATE( "KOI8-R" ), + wxTRANSLATE( "KOI8-U" ), wxTRANSLATE( "Windows Japanese (CP 932)" ), wxTRANSLATE( "Windows Chinese Simplified (CP 936)" ), wxTRANSLATE( "Windows Korean (CP 949)" ), @@ -124,6 +132,12 @@ static const wxChar* gs_encodingDescs[] = wxTRANSLATE( "Windows/DOS OEM (CP 437)" ), wxTRANSLATE( "Unicode 7 bit (UTF-7)" ), wxTRANSLATE( "Unicode 8 bit (UTF-8)" ), + wxTRANSLATE( "Unicode 16 bit (UTF-16)" ), + wxTRANSLATE( "Unicode 16 bit Big Endian (UTF-16BE)" ), + wxTRANSLATE( "Unicode 16 bit Little Endian (UTF-16LE)" ), + wxTRANSLATE( "Unicode 32 bit (UTF-32)" ), + wxTRANSLATE( "Unicode 32 bit Big Endian (UTF-32BE)" ), + wxTRANSLATE( "Unicode 32 bit Little Endian (UTF-32LE)" ), wxTRANSLATE( "Extended Unix Codepage for Japanese (EUC-JP)" ), }; @@ -146,6 +160,7 @@ static const wxChar* gs_encodingNames[] = wxT( "iso-8859-14" ), wxT( "iso-8859-15" ), wxT( "koi8-r" ), + wxT( "koi8-u" ), wxT( "windows-932" ), wxT( "windows-936" ), wxT( "windows-949" ), @@ -161,6 +176,12 @@ static const wxChar* gs_encodingNames[] = wxT( "windows-437" ), wxT( "utf-7" ), wxT( "utf-8" ), + wxT( "utf-16" ), + wxT( "utf-16be" ), + wxT( "utf-16le" ), + wxT( "utf-32" ), + wxT( "utf-32be" ), + wxT( "utf-32le" ), wxT( "euc-jp" ), }; @@ -177,7 +198,7 @@ class wxFontMapperModule : public wxModule { public: wxFontMapperModule() : wxModule() { } - virtual bool OnInit() { return TRUE; } + virtual bool OnInit() { return true; } virtual void OnExit() { delete wxFontMapper::Set(NULL); } DECLARE_DYNAMIC_CLASS(wxFontMapperModule) @@ -200,7 +221,7 @@ wxFontMapperBase::wxFontMapperBase() { #if wxUSE_CONFIG && wxUSE_FILECONFIG m_config = NULL; - m_configIsDummy = FALSE; + m_configIsDummy = false; #endif // wxUSE_CONFIG } @@ -274,7 +295,7 @@ wxConfigBase *wxFontMapperBase::GetConfig() if ( !m_config ) { // try the default - m_config = wxConfig::Get(FALSE /*don't create on demand*/ ); + m_config = wxConfig::Get(false /*don't create on demand*/ ); if ( !m_config ) { @@ -284,7 +305,7 @@ wxConfigBase *wxFontMapperBase::GetConfig() // but will allow us to remember the results of the questions at // least during this run m_config = new wxMemoryConfig; - m_configIsDummy = TRUE; + m_configIsDummy = true; // VS: we can't call wxConfig::Set(m_config) here because that would // disable automatic wxConfig instance creation if this code was // called before wxApp::OnInit (this happens in wxGTK -- it sets @@ -292,13 +313,13 @@ wxConfigBase *wxFontMapperBase::GetConfig() } } - if ( m_configIsDummy && wxConfig::Get(FALSE) != NULL ) + if ( m_configIsDummy && wxConfig::Get(false) != NULL ) { // VS: in case we created dummy m_config (see above), we want to switch back // to the real one as soon as one becomes available. delete m_config; - m_config = wxConfig::Get(FALSE); - m_configIsDummy = FALSE; + m_config = wxConfig::Get(false); + m_configIsDummy = false; // FIXME: ideally, we should add keys from dummy config to the real one now, // but it is a low-priority task because typical wxWin application // either doesn't use wxConfig at all or creates wxConfig object in @@ -328,7 +349,7 @@ bool wxFontMapperBase::ChangePath(const wxString& pathNew, wxString *pathOld) { wxConfigBase *config = GetConfig(); if ( !config ) - return FALSE; + return false; *pathOld = config->GetPath(); @@ -345,7 +366,7 @@ bool wxFontMapperBase::ChangePath(const wxString& pathNew, wxString *pathOld) config->SetPath(path); - return TRUE; + return true; } void wxFontMapperBase::RestorePath(const wxString& pathOld) @@ -416,7 +437,7 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) config->SetPath(FONTMAPPER_CHARSET_ALIAS_PATH); wxString alias = config->Read(charset); - if ( !!alias ) + if ( !alias.IsEmpty() ) { // yes, we do - use it instead cs = alias; @@ -455,6 +476,30 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) { encoding = wxFONTENCODING_UTF8; } + else if ( cs == wxT("UTF-16") ) + { + encoding = wxFONTENCODING_UTF16; + } + else if ( cs == wxT("UTF-16BE") ) + { + encoding = wxFONTENCODING_UTF16BE; + } + else if ( cs == wxT("UTF-16LE") ) + { + encoding = wxFONTENCODING_UTF16LE; + } + else if ( cs == wxT("UTF-32") || cs == wxT("UCS-4") ) + { + encoding = wxFONTENCODING_UTF32; + } + else if ( cs == wxT("UTF-32BE") || cs == wxT("UCS-4BE") ) + { + encoding = wxFONTENCODING_UTF32BE; + } + else if ( cs == wxT("UTF-32LE") || cs == wxT("UCS-4LE") ) + { + encoding = wxFONTENCODING_UTF32LE; + } else if ( cs == wxT("GB2312") ) { encoding = wxFONTENCODING_GB2312; @@ -474,15 +519,23 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) { encoding = wxFONTENCODING_EUC_JP; } + else if ( cs == wxT("EUC-KR") || + cs == wxT("EUC_KR") ) + { + encoding = wxFONTENCODING_CP949; + } else if ( cs == wxT("KOI8-R") || - cs == wxT("KOI8-U") || cs == wxT("KOI8-RU") ) { // although koi8-ru is not strictly speaking the same as koi8-r, // they are similar enough to make mapping it to koi8 better than - // not reckognizing it at all + // not recognizing it at all encoding = wxFONTENCODING_KOI8; } + else if ( cs == wxT("KOI8-U") ) + { + encoding = wxFONTENCODING_KOI8_U; + } else if ( cs.Left(3) == wxT("ISO") ) { // the dash is optional (or, to be exact, it is not, but @@ -490,14 +543,14 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) const wxChar *p = cs.c_str() + 3; if ( *p == wxT('-') ) p++; - + // printf( "iso %s\n", (const char*) cs.ToAscii() ); unsigned int value; if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 ) { // printf( "value %d\n", (int)value ); - + // make it 0 based and check that it is strictly positive in // the process (no such thing as iso8859-0 encoding) if ( (value-- > 0) && @@ -513,12 +566,12 @@ wxFontMapperBase::NonInteractiveCharsetToEncoding(const wxString& charset) else if ( cs.Left(4) == wxT("8859") ) { const wxChar *p = cs.c_str(); - + unsigned int value; if ( wxSscanf(p, wxT("8859-%u"), &value) == 1 ) { // printf( "value %d\n", (int)value ); - + // make it 0 based and check that it is strictly positive in // the process (no such thing as iso8859-0 encoding) if ( (value-- > 0) && @@ -658,5 +711,26 @@ wxString wxFontMapperBase::GetEncodingName(wxFontEncoding encoding) return str; } +/* static */ +wxFontEncoding wxFontMapperBase::GetEncodingFromName(const wxString& name) +{ + const size_t count = WXSIZEOF(gs_encodingNames); + + for ( size_t i = 0; i < count; i++ ) + { + if ( gs_encodingNames[i] == name ) + { + return gs_encodings[i]; + } + } + + if ( name == _("default") ) + { + return wxFONTENCODING_DEFAULT; + } + + return wxFONTENCODING_MAX; +} + #endif // wxUSE_FONTMAP