Пример #1
0
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
0
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
0
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
}