- if ( !Alloc(nLen) )
- {
- wxFAIL_MSG( _T("out of memory in wxString::wxString") );
- }
- else
- {
- wxCharBuffer buf(nLen);
- // WC2MB wants the buffer size, not the string length
- if ( conv.WC2MB(buf.data(), pwz, nLen + 1) != (size_t)-1 )
- {
- // initialized ok
- assign(buf.data(), nLen);
- return;
- }
- //else: the conversion failed -- leave the string empty (what else?)
- }
+ //Convert string
+ size_t nRealSize;
+ wxCharBuffer theBuffer = conv.cWC2MB(pwz, nLen, &nRealSize);
+
+ //Copy
+ if (nRealSize)
+ assign( theBuffer.data() , nRealSize - 1 );