本文整理汇总了C++中CStdStringW::length方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringW::length方法的具体用法?C++ CStdStringW::length怎么用?C++ CStdStringW::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringW
的用法示例。
在下文中一共展示了CStdStringW::length方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetCursorPos
void CGUILabelControl::SetCursorPos(int iPos)
{
CStdString labelUTF8 = m_infoLabel.GetLabel(m_parentID);
CStdStringW label;
g_charsetConverter.utf8ToW(labelUTF8, label);
if (iPos > (int)label.length()) iPos = label.length();
if (iPos < 0) iPos = 0;
if (m_iCursorPos != iPos)
MarkDirtyRegion();
m_iCursorPos = iPos;
}
示例2: TestTOCFields
void TestDocReader::TestTOCFields()
{
DocReader dr;
dr.OpenFile(TEST_TOC_DOC);
CStdStringW sGot = dr.GetMainDocumentText();
CStdStringW sExp = L"Table of Contents\rTable of Contents\t1\rNote\t4\rAppendix B – Calculation of font (FTC) and language (LID)\t178\r\r";
for (unsigned int i=0; i<(x64_int_cast)sGot.size(); i++)
{
switch (sGot[i])
{
case 19:
OutputDebugString(_T("<start>"));
break;
case 20:
OutputDebugString(_T("<result>"));
break;
case 21:
OutputDebugString(_T("<end>"));
break;
default:
{
CStdStringW s = sGot.Mid(i,1);
OutputDebugString(CStdString(s));
}
}
}
assertTest(sGot.Left(sExp.length()) == sExp);
}
示例3: GetDefaultSaveExtensionFromFormatString
CStdStringW FacadeDocumentProviderImpl::GetDefaultSaveExtensionFromFormatString(const CStdStringW& sAvailableFormats, long lIndex)
{
if(sAvailableFormats.IsEmpty())
return _T("wdf");
int iStartPos = -1;
int lSkip = (lIndex-1)*2;
for (int i=0; i<lSkip; i++)
{
iStartPos = sAvailableFormats.Find(_T('|'),iStartPos);
}
int iFirstDelimeterPos = sAvailableFormats.Find(_T('|'), iStartPos);
if (iFirstDelimeterPos == iStartPos+1) // we've hit the "||" at the end ...
iFirstDelimeterPos = sAvailableFormats.Find(_T('|')); // go back to default
int iNextDelimeterPos = sAvailableFormats.Find(_T('|'),iFirstDelimeterPos);
CStdStringW sExt = sAvailableFormats.Mid(iFirstDelimeterPos + 1 ,iNextDelimeterPos - iFirstDelimeterPos - 1 );
int iPeriodPos = sExt.Find(_T('.'));
sExt = sExt.Mid(iPeriodPos + 1, sExt.length() - iPeriodPos );
return sExt;
}
示例4: sizeof
void CCharsetConverter::utf16BEtoUTF8(const CStdStringW& strSource, CStdStringA &strDest)
{
if (m_iconvUtf16BEtoUtf8 == (iconv_t) - 1)
m_iconvUtf16BEtoUtf8 = iconv_open("UTF-8", "UTF-16BE");
if (m_iconvUtf16BEtoUtf8 != (iconv_t) - 1)
{
size_t inBytes = (strSource.length() + 1) * sizeof(wchar_t);
size_t outBytes = (strSource.length() + 1) * 4;
const char *src = (const char*) strSource.c_str();
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16BEtoUtf8, &src, &inBytes, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv(m_iconvUtf16BEtoUtf8, NULL, NULL, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例5: TestTableChanges
void TestDocReader::TestTableChanges()
{
DocReader dr;
dr.OpenFile(TEST_TABLE_TC_DOC);
CStdStringW sGot = dr.GetMainDocumentText();
CStdStringW sExp = L"Some stuff before the table\r\rA\07e\07d\07d\07c\07B\07C";
assertTest(sGot.Left(sExp.length()) == sExp);
}
示例6:
void CCharsetConverter::utf16LEtoUTF8(const CStdStringW& strSource, CStdStringA &strDest)
{
if (m_iconvUtf16LEtoUtf8 == (iconv_t) - 1)
m_iconvUtf16LEtoUtf8 = iconv_open("UTF-8", "UTF-16LE");
if (m_iconvUtf16LEtoUtf8 != (iconv_t) - 1)
{
const char* src = (const char*) strSource.c_str();
size_t inBytes = (strSource.length() + 1)*sizeof(wchar_t);
size_t outBytes = (inBytes + 1)*sizeof(wchar_t); // UTF-8 is up to 4 bytes/character
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16LEtoUtf8, &src, &inBytes, &dst, &outBytes))
{ // failed :(
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例7: sizeof
void CCharsetConverter::ucs2CharsetToStringCharset(const CStdStringW& strSource, CStdStringA& strDest, bool swap)
{
if (m_iconvUcs2CharsetToStringCharset == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetGuiCharSet();
m_iconvUcs2CharsetToStringCharset = iconv_open(strCharset.c_str(), "UTF-16LE");
}
if (m_iconvUcs2CharsetToStringCharset != (iconv_t) - 1)
{
const char* src = (const char*) strSource.c_str();
size_t inBytes = (strSource.length() + 1) * sizeof(wchar_t);
if (swap)
{
char* s = (char*) src;
while (*s || *(s + 1))
{
char c = *s;
*s = *(s + 1);
*(s + 1) = c;
s++;
s++;
}
}
char *dst = strDest.GetBuffer(inBytes);
size_t outBytes = inBytes;
if (iconv_const(m_iconvUcs2CharsetToStringCharset, &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();
}
}
示例8: SetTagValueBinary
void CMusicInfoTagLoaderWMA::SetTagValueBinary(const CStdString& strFrameName, const unsigned char* pValue, CMusicInfoTag& tag)
{
if (strFrameName == "WM/Picture")
{
WM_PICTURE picture;
int iPicOffset = 0;
// Picture types: http://msdn.microsoft.com/library/en-us/wmform/htm/wm_picture.asp
picture.bPictureType = (BYTE)pValue[iPicOffset];
iPicOffset += 1;
picture.dwDataLen = (DWORD)pValue[iPicOffset] + (pValue[iPicOffset + 1] * 0x100) + (pValue[iPicOffset + 2] * 0x10000);
iPicOffset += 4;
CStdStringW wString;
CStdString16 utf16String = (uint16_t*)(pValue+iPicOffset);
g_charsetConverter.utf16LEtoW(utf16String, wString);
g_charsetConverter.wToUTF8(wString, picture.pwszMIMEType);
iPicOffset += (wString.length() * 2);
iPicOffset += 2;
utf16String = (uint16_t*)(pValue+iPicOffset);
g_charsetConverter.utf16LEtoW(utf16String, picture.pwszDescription);
iPicOffset += (picture.pwszDescription.length() * 2);
iPicOffset += 2;
picture.pbData = (BYTE *)(pValue + iPicOffset);
// many wma's don't have the bPictureType specified. For now, just take
// Cover Front (3) or Other (0) as the cover.
if (picture.bPictureType == 3 || picture.bPictureType == 0) // Cover Front
{
CStdString strExtension(picture.pwszMIMEType);
// if we don't have an album tag, cache with the full file path so that
// other non-tagged files don't get this album image
CStdString strCoverArt;
if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty()))
strCoverArt = CUtil::GetCachedAlbumThumb(tag.GetAlbum(), tag.GetAlbumArtist().IsEmpty() ? tag.GetArtist() : tag.GetAlbumArtist());
else
strCoverArt = CUtil::GetCachedMusicThumb(tag.GetURL());
if (!CUtil::ThumbExists(strCoverArt))
{
int nPos = strExtension.Find('/');
if (nPos > -1)
strExtension.Delete(0, nPos + 1);
if (picture.pbData != NULL && picture.dwDataLen > 0)
{
if (CPicture::CreateThumbnailFromMemory(picture.pbData, picture.dwDataLen, strExtension, strCoverArt))
{
CUtil::ThumbCacheAdd(strCoverArt, true);
}
else
{
CUtil::ThumbCacheAdd(strCoverArt, false);
CLog::Log(LOGERROR, "Tag loader wma: "
"Unable to create album art for %s "
"(extension=%s, size=%u)",
tag.GetURL().c_str(), strExtension.c_str(),
picture.dwDataLen);
}
}
}
}
}
}