本文整理汇总了C++中CStdStringW::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringW::GetBuffer方法的具体用法?C++ CStdStringW::GetBuffer怎么用?C++ CStdStringW::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringW
的用法示例。
在下文中一共展示了CStdStringW::GetBuffer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void CCharsetConverter::utf16LEtoW(const char* strSource, CStdStringW &strDest)
{
if (m_iconvUtf16LEtoW == (iconv_t) - 1)
m_iconvUtf16LEtoW = iconv_open(WCHAR_CHARSET, "UTF-16LE");
if (m_iconvUtf16LEtoW != (iconv_t) - 1)
{
size_t inBytes = 2;
short* s = (short*) strSource;
while (*s != 0)
{
s++;
inBytes += 2;
}
size_t outBytes = (inBytes + 1)*sizeof(wchar_t); // UTF-8 is up to 4 bytes/character
char *dst = (char*) strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16LEtoW, &strSource, &inBytes, &dst, &outBytes))
{ // failed :(
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例2: subtitleCharsetToW
void CCharsetConverter::subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest)
{
CStdStringA strFlipped;
// No need to flip hebrew/arabic as mplayer does the flipping
if (m_iconvSubtitleCharsetToW == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetSubtitleCharSet();
m_iconvSubtitleCharsetToW = iconv_open(WCHAR_CHARSET, strCharset.c_str());
}
if (m_iconvSubtitleCharsetToW != (iconv_t) - 1)
{
const char* src = strSource.c_str();
size_t inBytes = strSource.length() + 1;
char *dst = (char*)strDest.GetBuffer(inBytes * sizeof(wchar_t));
size_t outBytes = inBytes * sizeof(wchar_t);
if (iconv_const(m_iconvSubtitleCharsetToW, &src, &inBytes, &dst, &outBytes))
{
strDest.ReleaseBuffer();
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
strDest = strSource;
}
strDest.ReleaseBuffer();
}
}
示例3: ReadWideString
CStdStringW DocReader::ReadWideString(int iOffset, int iCharCount)
{
CStdStringW sResult;
ReadIntoBufferIgnoringBitsInDeletedList(iOffset, iCharCount*2, sResult.GetBuffer(iCharCount + 1), iCharCount*2 + 2);
sResult.ReleaseBuffer();
return sResult;
}
示例4: MakePath
CStdStringW CFilename::MakePath()
{
CStdStringW res;
_wmakepath(res.GetBuffer(MAX_PATH),
drive.c_str(), dir.c_str(), fname.c_str(), ext.c_str());
res.ReleaseBuffer();
return res;
}
示例5: logicalToVisualBiDi
// The bVisualBiDiFlip forces a flip of characters for hebrew/arabic languages, only set to false if the flipping
// of the string is already made or the string is not displayed in the GUI
void CCharsetConverter::utf8ToW(const CStdStringA& utf8String, CStdStringW &wString, bool bVisualBiDiFlip/*=true*/)
{
CStdStringA strFlipped;
const char* src;
size_t inBytes;
// Try to flip hebrew/arabic characters, if any
if (bVisualBiDiFlip)
{
logicalToVisualBiDi(utf8String, strFlipped, FRIBIDI_CHAR_SET_UTF8);
src = strFlipped.c_str();
inBytes = strFlipped.length() + 1;
}
else
{
src = utf8String.c_str();
inBytes = utf8String.length() + 1;
}
if (m_iconvUtf8toW == (iconv_t) - 1)
m_iconvUtf8toW = iconv_open(WCHAR_CHARSET, UTF8_SOURCE);
if (m_iconvUtf8toW != (iconv_t) - 1)
{
size_t outBytes = inBytes * sizeof(wchar_t);
char * dst = (char*)wString.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf8toW, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
wString.ReleaseBuffer();
wString = utf8String;
return;
}
if (iconv(m_iconvUtf8toW, NULL, NULL, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
wString.ReleaseBuffer();
wString = utf8String;
return;
}
wString.ReleaseBuffer();
}
}
示例6: subtitleCharsetToW
void CCharsetConverter::subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest)
{
CStdStringA strFlipped;
// No need to flip hebrew/arabic as mplayer does the flipping
if (m_iconvSubtitleCharsetToW == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetSubtitleCharSet();
m_iconvSubtitleCharsetToW = iconv_open(WCHAR_CHARSET, strCharset.c_str());
}
if (m_iconvSubtitleCharsetToW != (iconv_t) - 1)
{
size_t inBytes = (strSource.length() + 1);
size_t outBytes = (strSource.length() + 1) * sizeof(wchar_t);
const char *src = strSource.c_str();
char *dst = (char*)strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvSubtitleCharsetToW, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv_const(m_iconvSubtitleCharsetToW, NULL, NULL, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}