- size_t len = wxConvLibc.FromWChar(out, outsize, buf);
- if ( len != wxCONV_FAILED )
- return len-1;
- else
- return wxConvLibc.FromWChar(NULL, 0, buf);
+ const size_t len = buf.length();
+ if ( outsize > len )
+ {
+ memcpy(out, buf, len+1);
+ }
+ else // not enough space
+ {
+ memcpy(out, buf, outsize-1);
+ out[outsize-1] = '\0';
+ }
+
+ return len;