- // empty?
- if ( (nLen != 0) && (nLen != (size_t)-1) ) {
- if ( !AllocBuffer(nLen) ) {
- wxFAIL_MSG( _T("out of memory in wxString::wxString") );
- return;
+ // anything to do?
+ if ( (nLen != 0) && (nLen != (size_t)-1) )
+ {
+ if ( !AllocBuffer(nLen) )
+ {
+ wxFAIL_MSG( _T("out of memory in wxString::wxString") );
+ return;
+ }
+
+ // WC2MB wants the buffer size, not the string length
+ if ( conv.WC2MB(m_pchData, pwz, nLen + 1) != (size_t)-1 )
+ {
+ // initialized ok
+ return;
+ }
+ //else: the conversion failed -- leave the string empty (what else?)