don't crash, even if used incorrectly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13800 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-01-25 14:30:11 +00:00
parent cafbf6fb1f
commit 307fd9567e

View File

@@ -182,7 +182,7 @@ void wxEncodingConverter::Convert(const char* input, char* output)
return; return;
} }
wxASSERT_MSG(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!")); wxCHECK_RET(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!"));
for (i = input, o = output; *i != 0;) for (i = input, o = output; *i != 0;)
*(o++) = (char)(m_Table[(wxUint8)*(i++)]); *(o++) = (char)(m_Table[(wxUint8)*(i++)]);
@@ -208,7 +208,7 @@ void wxEncodingConverter::Convert(const char* input, wchar_t* output)
return; return;
} }
wxASSERT_MSG(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!")); wxCHECK_RET(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!"));
for (i = input, o = output; *i != 0;) for (i = input, o = output; *i != 0;)
*(o++) = (wchar_t)(m_Table[(wxUint8)*(i++)]); *(o++) = (wchar_t)(m_Table[(wxUint8)*(i++)]);
@@ -233,7 +233,7 @@ void wxEncodingConverter::Convert(const wchar_t* input, char* output)
return; return;
} }
wxASSERT_MSG(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!")); wxCHECK_RET(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!"));
for (i = input, o = output; *i != 0;) for (i = input, o = output; *i != 0;)
*(o++) = (char)(m_Table[(wxUint16)*(i++)]); *(o++) = (char)(m_Table[(wxUint16)*(i++)]);
@@ -259,7 +259,7 @@ void wxEncodingConverter::Convert(const wchar_t* input, wchar_t* output)
return; return;
} }
wxASSERT_MSG(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!")); wxCHECK_RET(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!"));
for (i = input, o = output; *i != 0;) for (i = input, o = output; *i != 0;)
*(o++) = (wchar_t)(m_Table[(wxUint8)*(i++)]); *(o++) = (wchar_t)(m_Table[(wxUint8)*(i++)]);
@@ -276,14 +276,19 @@ wxString wxEncodingConverter::Convert(const wxString& input)
wxString s; wxString s;
const wxChar *i; const wxChar *i;
wxASSERT_MSG(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!")); wxCHECK_RET(m_Table != NULL, wxT("You must call wxEncodingConverter::Init() before actually converting!"));
if (m_UnicodeInput) if (m_UnicodeInput)
{
for (i = input.c_str(); *i != 0; i++) for (i = input.c_str(); *i != 0; i++)
s << (wxChar)(m_Table[(wxUint16)*i]); s << (wxChar)(m_Table[(wxUint16)*i]);
}
else else
{
for (i = input.c_str(); *i != 0; i++) for (i = input.c_str(); *i != 0; i++)
s << (wxChar)(m_Table[(wxUint8)*i]); s << (wxChar)(m_Table[(wxUint8)*i]);
}
return s; return s;
} }