+ rc -= GetMBNulLen();
+ }
+
+ return rc;
+}
+
+wxMBConv::~wxMBConv()
+{
+ // nothing to do here (necessary for Darwin linking probably)
+}
+
+const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const
+{
+ if ( psz )
+ {
+ // calculate the length of the buffer needed first
+ const size_t nLen = MB2WC(NULL, psz, 0);
+ if ( nLen != wxCONV_FAILED )
+ {
+ // now do the actual conversion
+ wxWCharBuffer buf(nLen /* +1 added implicitly */);
+
+ // +1 for the trailing NULL
+ if ( MB2WC(buf.data(), psz, nLen + 1) != wxCONV_FAILED )
+ return buf;
+ }
+ }
+
+ return wxWCharBuffer();
+}
+
+const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const
+{
+ if ( pwz )
+ {
+ const size_t nLen = WC2MB(NULL, pwz, 0);
+ if ( nLen != wxCONV_FAILED )
+ {
+ // extra space for trailing NUL(s)
+ static const size_t extraLen = GetMaxMBNulLen();
+
+ wxCharBuffer buf(nLen + extraLen - 1);
+ if ( WC2MB(buf.data(), pwz, nLen + extraLen) != wxCONV_FAILED )
+ return buf;
+ }
+ }
+
+ return wxCharBuffer();
+}
+
+const wxWCharBuffer
+wxMBConv::cMB2WC(const char *inBuff, size_t inLen, size_t *outLen) const
+{
+ const size_t dstLen = ToWChar(NULL, 0, inBuff, inLen);
+ if ( dstLen != wxCONV_FAILED )
+ {
+ wxWCharBuffer wbuf(dstLen - 1);
+ if ( ToWChar(wbuf.data(), dstLen, inBuff, inLen) != wxCONV_FAILED )