Move G_FILENAME_ENCODING to wxGTK
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -69,11 +69,6 @@ public:
|
|||||||
// or the XVisualInfo* for SGI.
|
// or the XVisualInfo* for SGI.
|
||||||
GdkVisual *GetGdkVisual();
|
GdkVisual *GetGdkVisual();
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
wxConvBrokenFileNames *m_convBrokenFileNames;
|
|
||||||
wxMBConv *m_oldConvFileName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// true if we're inside an assert modal dialog
|
// true if we're inside an assert modal dialog
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
@@ -69,11 +69,6 @@ public:
|
|||||||
// or the XVisualInfo* for SGI.
|
// or the XVisualInfo* for SGI.
|
||||||
GdkVisual *GetGdkVisual();
|
GdkVisual *GetGdkVisual();
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
wxConvBrokenFileNames *m_convBrokenFileNames;
|
|
||||||
wxMBConv *m_oldConvFileName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// true if we're inside an assert modal dialog
|
// true if we're inside an assert modal dialog
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
@@ -98,7 +98,7 @@ public:
|
|||||||
class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv
|
class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxConvBrokenFileNames();
|
wxConvBrokenFileNames(const wxChar *charset);
|
||||||
virtual ~wxConvBrokenFileNames() { delete m_conv; }
|
virtual ~wxConvBrokenFileNames() { delete m_conv; }
|
||||||
|
|
||||||
virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const;
|
virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const;
|
||||||
|
@@ -363,38 +363,13 @@ size_t wxMBConvLibc::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
|||||||
// wxConvBrokenFileNames
|
// wxConvBrokenFileNames
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxConvBrokenFileNames::wxConvBrokenFileNames()
|
wxConvBrokenFileNames::wxConvBrokenFileNames(const wxChar *charset)
|
||||||
{
|
{
|
||||||
// decide which conversion to use for the file names
|
if ( !charset || wxStricmp(charset, _T("UTF-8")) == 0
|
||||||
|
|| wxStricmp(charset, _T("UTF8")) == 0 )
|
||||||
// (1) this variable exists for the sole purpose of specifying the encoding
|
m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL);
|
||||||
// of the filenames for GTK+ programs, so use it if it is set
|
else
|
||||||
wxString encName(wxGetenv(_T("G_FILENAME_ENCODING")));
|
m_conv = new wxCSConv(charset);
|
||||||
encName.MakeUpper();
|
|
||||||
if ( !encName.empty() && encName != _T("UTF-8") && encName != _T("UTF8") )
|
|
||||||
{
|
|
||||||
m_conv = new wxCSConv(encName);
|
|
||||||
}
|
|
||||||
else // no G_FILENAME_ENCODING
|
|
||||||
{
|
|
||||||
#if wxUSE_INTL
|
|
||||||
if ( encName.empty() )
|
|
||||||
encName = wxLocale::GetSystemEncodingName().Upper();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// (2) if a non default locale is set, assume that the user wants his
|
|
||||||
// filenames in this locale too
|
|
||||||
if ( !encName.empty() && encName != _T("UTF-8") && encName != _T("UTF8") )
|
|
||||||
{
|
|
||||||
wxSetEnv(_T("G_FILENAME_ENCODING"), encName);
|
|
||||||
m_conv = new wxCSConv(encName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// (3) finally use UTF-8 by default
|
|
||||||
m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
@@ -607,10 +607,30 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
m_convBrokenFileNames = new wxConvBrokenFileNames;
|
// decide which conversion to use for the file names
|
||||||
m_oldConvFileName = wxConvFileName;
|
|
||||||
wxConvFileName = m_convBrokenFileNames;
|
// (1) this variable exists for the sole purpose of specifying the encoding
|
||||||
#endif
|
// of the filenames for GTK+ programs, so use it if it is set
|
||||||
|
wxString encName(wxGetenv(_T("G_FILENAME_ENCODING")));
|
||||||
|
encName.MakeUpper();
|
||||||
|
#if wxUSE_INTL
|
||||||
|
if (encName.empty())
|
||||||
|
{
|
||||||
|
// (2) if a non default locale is set, assume that the user wants his
|
||||||
|
// filenames in this locale too
|
||||||
|
encName = wxLocale::GetSystemEncodingName().Upper();
|
||||||
|
// (3) finally use UTF-8 by default
|
||||||
|
if (encName.empty() || encName == _T("US-ASCII"))
|
||||||
|
encName = _T("UTF-8");
|
||||||
|
wxSetEnv(_T("G_FILENAME_ENCODING"), encName);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (encName.empty())
|
||||||
|
encName = _T("UTF-8");
|
||||||
|
#endif // wxUSE_INTL
|
||||||
|
static wxConvBrokenFileNames fileconv(encName);
|
||||||
|
wxConvFileName = &fileconv;
|
||||||
|
#endif // __WXGTK20__
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||||
@@ -686,11 +706,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
delete m_convBrokenFileNames;
|
|
||||||
wxConvFileName = m_oldConvFileName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
wxAppBase::CleanUp();
|
wxAppBase::CleanUp();
|
||||||
|
@@ -607,10 +607,30 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
m_convBrokenFileNames = new wxConvBrokenFileNames;
|
// decide which conversion to use for the file names
|
||||||
m_oldConvFileName = wxConvFileName;
|
|
||||||
wxConvFileName = m_convBrokenFileNames;
|
// (1) this variable exists for the sole purpose of specifying the encoding
|
||||||
#endif
|
// of the filenames for GTK+ programs, so use it if it is set
|
||||||
|
wxString encName(wxGetenv(_T("G_FILENAME_ENCODING")));
|
||||||
|
encName.MakeUpper();
|
||||||
|
#if wxUSE_INTL
|
||||||
|
if (encName.empty())
|
||||||
|
{
|
||||||
|
// (2) if a non default locale is set, assume that the user wants his
|
||||||
|
// filenames in this locale too
|
||||||
|
encName = wxLocale::GetSystemEncodingName().Upper();
|
||||||
|
// (3) finally use UTF-8 by default
|
||||||
|
if (encName.empty() || encName == _T("US-ASCII"))
|
||||||
|
encName = _T("UTF-8");
|
||||||
|
wxSetEnv(_T("G_FILENAME_ENCODING"), encName);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (encName.empty())
|
||||||
|
encName = _T("UTF-8");
|
||||||
|
#endif // wxUSE_INTL
|
||||||
|
static wxConvBrokenFileNames fileconv(encName);
|
||||||
|
wxConvFileName = &fileconv;
|
||||||
|
#endif // __WXGTK20__
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||||
@@ -686,11 +706,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
|
||||||
delete m_convBrokenFileNames;
|
|
||||||
wxConvFileName = m_oldConvFileName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
wxAppBase::CleanUp();
|
wxAppBase::CleanUp();
|
||||||
|
Reference in New Issue
Block a user