本文整理汇总了C++中wxMBConv::cWC2MB方法的典型用法代码示例。如果您正苦于以下问题:C++ wxMBConv::cWC2MB方法的具体用法?C++ wxMBConv::cWC2MB怎么用?C++ wxMBConv::cWC2MB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxMBConv
的用法示例。
在下文中一共展示了wxMBConv::cWC2MB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test
// test that the conversion between str and wcs (subject to flags) succeeds
//
// the first argument is the index in the test array and is used solely for
// diagnostics
void Test(size_t n, wxMBConv& conv) const
{
if ( str )
{
wxWCharBuffer wbuf = conv.cMB2WC(str);
if ( wcs )
{
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "MB2WC failed"),
wbuf.data()
);
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "MB2WC", wbuf, wcs),
wxStrcmp(wbuf, wcs) == 0
);
}
else // conversion is supposed to fail
{
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "MB2WC succeeded"),
!wbuf.data()
);
}
}
if ( wcs && !(flags & ONLY_MB2WC) )
{
wxCharBuffer buf = conv.cWC2MB(wcs);
if ( str )
{
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "WC2MB failed"),
buf.data()
);
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "WC2MB", buf, str),
strcmp(buf, str) == 0
);
}
else
{
CPPUNIT_ASSERT_MESSAGE
(
Message(n, "WC2MB succeeded"),
!buf.data()
);
}
}
}
示例2: WriteLine
bool CTextFile::WriteLine(const wxString& line, const wxMBConv& conv)
{
wxCHECK_MSG(m_file.IsOpened(), false, wxT("Trying to read from closed file."));
wxCHECK_MSG((m_mode == write), false, wxT("Trying to read from non-readable file."));
// Ensures that use of newlines/carriage-returns matches the OS
wxString result = wxTextBuffer::Translate(line);
// Only add line-breaks between lines, as otherwise the number of
// lines would grow as the result of the addition of an empty line,
// at the end of the file.
if (m_file.Tell() > 0) {
result = wxTextBuffer::GetEOL() + result;
}
wxCharBuffer strBuffer = conv.cWC2MB(result);
if (strBuffer) {
const size_t length = strlen(strBuffer);
return (m_file.Write(strBuffer, length) == length);
}
return false;
}