本文整理汇总了C++中CStdStringW::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringW::Replace方法的具体用法?C++ CStdStringW::Replace怎么用?C++ CStdStringW::Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringW
的用法示例。
在下文中一共展示了CStdStringW::Replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertHTMLToW
void CHTMLUtil::ConvertHTMLToW(const CStdStringW& strHTML, CStdStringW& strStripped)
{
if (strHTML.size() == 0)
{
strStripped.Empty();
return ;
}
int iPos = 0;
strStripped = strHTML;
while (mappings[iPos].html)
{
strStripped.Replace(mappings[iPos].html,CStdStringW(1, mappings[iPos].w));
iPos++;
}
iPos = strStripped.Find(L"&#");
while (iPos > 0 && iPos < (int)strStripped.size()-4)
{
int iStart = iPos + 1;
iPos += 2;
CStdStringW num;
int base = 10;
if (strStripped[iPos+1] == L'x')
{
base = 16;
iPos++;
}
int i=iPos;
while ( iPos < (int)strStripped.size() &&
(base==16?iswxdigit(strStripped[iPos]):iswdigit(strStripped[iPos])))
iPos++;
num = strStripped.Mid(i,iPos-i);
wchar_t val = (wchar_t)wcstol(num.c_str(),NULL,base);
if (base == 10)
num.Format(L"&#%ls;",num.c_str());
else
num.Format(L"&#x%ls;",num.c_str());
strStripped.Replace(num,CStdStringW(1,val));
iPos = strStripped.Find(L"&#", iStart);
}
}
示例2: GetVersionInfo
HRESULT DMSHelper::GetVersionInfo(const CStdStringW& sDocVersionID, WSDocumentVersionNoCom &wsDocVersion)
{
LOG_WS_FUNCTION_SCOPE_MSG(sDocVersionID);
try
{
CStdStringW sDocID(sDocVersionID);
sDocID.Replace(L"\\",L"/");
std::vector<WSDocumentVersionNoCom>::iterator itr;
std::vector<WSDocumentVersionNoCom> vecVersions = GetVersions(sDocID);
if(vecVersions.size() == 0)
{
CStdString sErr;
sErr.Format(L"Failed to get versions for doc ID [%s]", sDocID);
LOG_WS_ERROR(sErr.c_str());
return E_FAIL;
}
for(itr = vecVersions.begin(); itr != vecVersions.end(); itr++)
{
CStdStringW sVersionDocID = itr->GetWSDocument().GetDocId();
sVersionDocID.Replace(L"\\",L"/");
if(sDocID.CompareNoCase(sVersionDocID) == 0 )
{
wsDocVersion = *itr;
return S_OK;
}
}
CStdString sMsg;
sMsg.Format(L"Failed to get versions for doc ID [%s]", sDocID);
LOG_WS_INFO(sMsg.c_str());
}
catch(_com_error &e)
{
LOG_WS_ERROR_RESULT(e);
return e.Error();
}
catch(...)
{
LOG_WS_ERROR(_T("Unknown Exception"));
return E_FAIL;
}
return E_DOCUMENT_NOT_FOUND;
}
示例3:
void CGUITextLayout::utf8ToW(const CStdString &utf8, CStdStringW &utf16)
{
#ifdef WORK_AROUND_NEEDED_FOR_LINE_BREAKS
// NOTE: This appears to strip \n characters from text. This may be a consequence of incorrect
// expression of the \n in utf8 (we just use character code 10) or it might be something
// more sinister. For now, we use the workaround below.
CStdStringArray multiLines;
StringUtils::SplitString(utf8, "\n", multiLines);
for (unsigned int i = 0; i < multiLines.size(); i++)
{
CStdStringW line;
g_charsetConverter.utf8ToW(multiLines[i], line);
line.Replace(L"\r", L""); // filter out '\r'
utf16 += line;
if (i < multiLines.size() - 1)
utf16.push_back(L'\n');
}
#else
g_charsetConverter.utf8ToW(utf8, utf16);
#endif
}