static int FindAsciiLower(const CStringA &str, const CStringA &find) { if (find.GetLength() == 0) return 0; for (int i = 0; i < str.GetLength(); ++i) { char c = str[i]; c += (c >= 'A' && c <= 'Z') ? 32 : 0; if (c == find[0]) { bool diff = false; int k = 1; for (int j = i + 1; j < str.GetLength() && k < find.GetLength(); ++j, ++k) { char d = str[j]; d += (d >= 'A' && d <= 'Z') ? 32 : 0; if (d != find[k]) { diff = true; break; } } if (!diff && k == find.GetLength()) return i; } } return -1; }
bool CStringUtils::WriteDiffToClipboard(const CStringA& sClipdata, HWND hOwningWnd) { UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF")); if (cFormat == 0) return false; CClipboardHelper clipboardHelper; if (clipboardHelper.Open(hOwningWnd)) { EmptyClipboard(); HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc(sClipdata.GetLength()+1); if (hClipboardData) { char* pchData = (char*)GlobalLock(hClipboardData); if (pchData) { strcpy_s(pchData, sClipdata.GetLength()+1, (LPCSTR)sClipdata); GlobalUnlock(hClipboardData); if (SetClipboardData(cFormat,hClipboardData)==NULL) { return false; } if (SetClipboardData(CF_TEXT,hClipboardData)) { return true; } } } } return false; }
bool CStringUtils::WriteAsciiStringToClipboard(const CStringA& sClipdata, LCID lcid, HWND hOwningWnd) { CClipboardHelper clipboardHelper; if (clipboardHelper.Open(hOwningWnd)) { EmptyClipboard(); HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc(sClipdata.GetLength()+1); if (hClipboardData) { char* pchData = (char*)GlobalLock(hClipboardData); if (pchData) { strcpy_s(pchData, sClipdata.GetLength()+1, (LPCSTR)sClipdata); GlobalUnlock(hClipboardData); if (SetClipboardData(CF_TEXT, hClipboardData)) { HANDLE hlocmem = CClipboardHelper::GlobalAlloc(sizeof(LCID)); if (hlocmem) { PLCID plcid = (PLCID)GlobalLock(hlocmem); if (plcid) { *plcid = lcid; SetClipboardData(CF_LOCALE, static_cast<HANDLE>(plcid)); } GlobalUnlock(hlocmem); } return true; } } } } return false; }
//Notification handler BOOL CMdiView::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { UNREFERENCED_PARAMETER(id); UNREFERENCED_PARAMETER(pResult); // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; CStringA strTipText; UINT_PTR nID = pNMHDR->idFrom; if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); } if (nID != 0) // will be zero on a separator strTipText.Format("Control ID = %d", nID); if (pNMHDR->code == TTN_NEEDTEXTA) { strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, strTipText.GetLength() + 1); } else { ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, pTTTW->szText, sizeof(pTTTW->szText)/(sizeof pTTTW->szText[0])); } return TRUE; // message was handled }
CStringA Util::String::PHP_URLDecode( const CStringA& src ) { CStringA decodeURL; for(int i = 0; i < src.GetLength(); i++) { unsigned char ch = 0; if(src[i]=='%') { ATLASSERT(i + 2 < src.GetLength()); unsigned char c1 = src[i + 1]; unsigned char c2 = src[i + 2]; ch = ((FromHex(c1) << 4) & 0xf0); ch |= (FromHex(c2) & 0x0f); i += 2; } else if(src[i] == '+') { ch = ' '; } else { ch = src[i]; } decodeURL += (unsigned char)ch; } return decodeURL; }
void CVNOCLoginDlg::OnBnClickedOk() { UpdateData(TRUE); Global->Logf(LogFile_Net,_T("登陆操作,用户名:%s 密码:%s\n"), m_strUsername, m_strPassword); if (m_strUsername.IsEmpty()) { OnOK(); } SHA1 shaer; shaer.Reset(); CStringA pwdBuffer = CT2A(m_strPassword); shaer.Input(pwdBuffer,pwdBuffer.GetLength()); UINT pResult[5]; shaer.Result(pResult); pwdBuffer.Format("%08x%08x%08x%08x%08x" ,pResult[0],pResult[1],pResult[2],pResult[3],pResult[4]); Global->Logf(LogFile_General,_T("SHA1后的密码为:%s\n"),CA2T(pwdBuffer)); INetCenter *pInet=NULL; Global->GetINetCenter(&pInet); ATLASSERT(pInet); if (pInet) { MSG_RLI mRli; mRli.SetAccountNumber((byte*)(LPCTSTR)m_strUsername,m_strUsername.GetLength()*sizeof(TCHAR)); mRli.SetPassword((byte*)(LPCSTR)pwdBuffer,pwdBuffer.GetLength()*sizeof(TCHAR)); pInet->SendServer(mRli); _SetVerifyState(TRUE); SetTimer(0,5000,NULL); } }
BOOL CMessageBox::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case 'C': case VK_INSERT: { if (GetAsyncKeyState(VK_CONTROL)&0x8000) { CClipboardHelper clipboardHelper; if(clipboardHelper.Open(GetSafeHwnd())) { EmptyClipboard(); CStringA sClipboard = CStringA(m_sMessage); HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc(sClipboard.GetLength()+1); char * pchData = (char*)GlobalLock(hClipboardData); if (pchData) strcpy_s(pchData, sClipboard.GetLength()+1, (LPCSTR)sClipboard); GlobalUnlock(hClipboardData); SetClipboardData(CF_TEXT,hClipboardData); } return TRUE; } } break; case VK_ESCAPE: { switch (m_uType & 0xf) { case MB_ABORTRETRYIGNORE: EndDialog(m_uButton1Ret); break; case MB_CANCELTRYCONTINUE: EndDialog(m_uButton1Ret); break; case MB_OKCANCEL: EndDialog(m_uButton2Ret); break; case MB_RETRYCANCEL: EndDialog(m_uButton2Ret); break; case MB_YESNO: EndDialog(m_uButton2Ret); break; case MB_YESNOCANCEL: EndDialog(m_uButton3Ret); break; } } break; } } return __super::PreTranslateMessage(pMsg); }
CStringA CAppUtils::PathUnescape(const CStringA& path) { std::unique_ptr<char> urlabuf (new char[path.GetLength()+1]); strcpy_s(urlabuf.get(), path.GetLength()+1, path); Unescape(urlabuf.get()); return urlabuf.get(); }
CStringA CPathUtils::PathUnescape(const CStringA& path) { auto urlabuf = std::make_unique<char[]>(path.GetLength() + 1); strcpy_s(urlabuf.get(), path.GetLength()+1, path); Unescape(urlabuf.get()); return urlabuf.get(); }
CStringW Util::String::GBKToUnicode( CStringA gbk ) { CStringW strUnicode; DWORD dwMinSize = 0; dwMinSize = MultiByteToWideChar(936, NULL, gbk, gbk.GetLength(),NULL, 0); strUnicode.GetBufferSetLength(dwMinSize); LPWSTR lpszStr = strUnicode.GetBuffer(); INT ok = MultiByteToWideChar(936, NULL, gbk, gbk.GetLength(), lpszStr, dwMinSize); strUnicode.ReleaseBuffer(); return strUnicode; }
bool CStringUtils::WriteDiffToClipboard(const CStringA& sClipdata, HWND hOwningWnd) { UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF")); if (cFormat == 0) return false; if (OpenClipboard(hOwningWnd)) { EmptyClipboard(); HGLOBAL hClipboardData; hClipboardData = GlobalAlloc(GMEM_DDESHARE, sClipdata.GetLength()+1); if (hClipboardData) { char * pchData; pchData = (char*)GlobalLock(hClipboardData); if (pchData) { strcpy_s(pchData, sClipdata.GetLength()+1, (LPCSTR)sClipdata); if (GlobalUnlock(hClipboardData)) { if (SetClipboardData(cFormat,hClipboardData)==NULL) { CloseClipboard(); return false; } if (SetClipboardData(CF_TEXT,hClipboardData)==NULL) { CloseClipboard(); return false; } } else { CloseClipboard(); return false; } } else { CloseClipboard(); return false; } } else { CloseClipboard(); return false; } CloseClipboard(); return true; } return false; }
void DLrtfhtml::openfile(CString filename) { CStdioFile rtf; rtf.Open(_T("F:\\\\itbook2.tit"),CStdioFile::modeRead); int len=rtf.GetLength(); rtf.SeekToBegin(); CStringA content; rtf.Read(content.GetBuffer(len),len); content.ReleaseBuffer(); rtf.Close(); char* str,*strd; str=strd=new char[len+1]; memset(str,'\0',sizeof(str)); int bg,end; bg=end=0; char* p; while((end=content.Find("\\\'",end))>=0) { if(end==0 || content.GetAt(end-1)!='\\') {//转汉字 CStringA s; if(end!=bg) { strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg,end-bg)); str+=(end-bg); } *str=strtol(content.Mid(end+2,2),&p,16); str++; bg=end+4; } else {// \\' 去斜杆 if(end!=bg) { strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg,end-bg-1)); // '之前还有两个" \ " str+=(end-bg-1); } strcpy(str,(LPSTR)(LPCSTR)content.Mid(end,2)); str+=2; bg=end+2; } end++; } int leng=content.GetLength(); if((content.GetLength()-bg)>2)//如果再最后两个字符找到\'则会=2 当然根据rtf文档绝对不会这样。 strcpy(str,(LPSTR)(LPCSTR)content.Mid(bg)); //} int unicodeLen = ::MultiByteToWideChar( CP_ACP,0,strd,-1,NULL,0); MultiByteToWideChar(CP_ACP,0,strd,-1,(LPWSTR)destcon.GetBuffer(unicodeLen),unicodeLen); destcon.ReleaseBuffer(); }
void ScintillaEditor::ReadPropertiesInitial() { ScintillaPropertiesFile& props = *m_props; int indentationWSVisible = props.GetInt("view.indentation.whitespace", 1); // ViewWhitespace(props.GetInt("view.whitespace")); SendEditor(SCI_SETINDENTATIONGUIDES, props.GetInt("view.indentation.guides")); SendEditor(SCI_SETVIEWEOL, props.GetInt("view.eol")); // sbVisible = props.GetInt("statusbar.visible"); // tbVisible = props.GetInt("toolbar.visible"); // tabVisible = props.GetInt("tabbar.visible"); // tabMultiLine = props.GetInt("tabbar.multiline"); #if PLAT_WIN // if (tabMultiLine) { // Windows specific! // long wl = ::GetWindowLong(wTabBar.GetID(), GWL_STYLE); // ::SetWindowLong(wTabBar.GetID(), GWL_STYLE, wl | TCS_MULTILINE); // } #endif lineNumbersWidth = 0; CStringA linenums = props.Get("line.numbers"); if (linenums.GetLength()) lineNumbersWidth = value(linenums); int lineNumbers = lineNumbersWidth; if (lineNumbersWidth == 0) lineNumbersWidth = lineNumbersWidthDefault; marginWidth = 0; CStringA margwidth = props.Get("margin.width"); if (margwidth.GetLength()) marginWidth = value(margwidth); margin = marginWidth != 0; if (marginWidth == 0) marginWidth = marginWidthDefault; foldMarginWidth = props.GetInt("fold.margin.width", foldMarginWidthDefault); foldMargin = foldMarginWidth != 0; if (foldMarginWidth == 0) foldMarginWidth = foldMarginWidthDefault; /* char homepath[MAX_PATH + 20]; if (GetSciteDefaultHome(homepath, sizeof(homepath))) { props.Set("SciteDefaultHome", homepath); } if (GetSciteUserHome(homepath, sizeof(homepath))) { props.Set("SciteUserHome", homepath); } */ }
CStringA ConvertMBCS(CStringA str, DWORD SrcCharSet, DWORD DstCharSet) { WCHAR* utf16 = new WCHAR[str.GetLength() + 1]; memset(utf16, 0, (str.GetLength() + 1)*sizeof(WCHAR)); CHAR* mbcs = new CHAR[str.GetLength() * 6 + 1]; memset(mbcs, 0, str.GetLength() * 6 + 1); int len = MultiByteToWideChar( CharSetToCodePage(SrcCharSet), 0, str.GetBuffer(str.GetLength()), str.GetLength(), utf16, (str.GetLength() + 1) * sizeof(WCHAR)); len = WideCharToMultiByte( CharSetToCodePage(DstCharSet), 0, utf16, len, mbcs, str.GetLength() * 6, NULL, NULL); str = mbcs; delete [] utf16; delete [] mbcs; return str; }
BOOL CStdioFileEx::ReadAnsiString(CStringA& rString) { _ASSERTE(m_pStream); rString = ""; // empty string without deallocating if(!m_bIsUnicodeText) { const int nMaxSize = 128; LPSTR lpsz = rString.GetBuffer(nMaxSize); LPSTR lpszResult; int nLen = 0; for (;;) { lpszResult = fgets(lpsz, nMaxSize+1, m_pStream); rString.ReleaseBuffer(); // handle error/eof case if (lpszResult == NULL && !feof(m_pStream)) { Afx_clearerr_s(m_pStream); AfxThrowFileException(CFileException::genericException, _doserrno, m_strFileName); } // if string is read completely or EOF if (lpszResult == NULL || (nLen = (int)lstrlenA(lpsz)) < nMaxSize || lpsz[nLen-1] == '\n') break; nLen = rString.GetLength(); lpsz = rString.GetBuffer(nMaxSize + nLen) + nLen; } //remove crlf if exist. nLen = rString.GetLength(); if (nLen > 1 && rString.Mid(nLen-2) == "\r\n") { rString.GetBufferSetLength(nLen-2); } return rString.GetLength() > 0; } else { CStringW wideString; BOOL bRetval = ReadWideString(wideString); //setlocale(LC_ALL, "chs_chn.936");//no need rString = wideString; return bRetval; } }
bool CStringUtils::WriteAsciiStringToClipboard(const CStringA& sClipdata, LCID lcid, HWND hOwningWnd) { if (OpenClipboard(hOwningWnd)) { EmptyClipboard(); HGLOBAL hClipboardData; hClipboardData = GlobalAlloc(GMEM_DDESHARE, sClipdata.GetLength()+1); if (hClipboardData) { char * pchData; pchData = (char*)GlobalLock(hClipboardData); if (pchData) { strcpy_s(pchData, sClipdata.GetLength()+1, (LPCSTR)sClipdata); if (GlobalUnlock(hClipboardData)) { if (SetClipboardData(CF_TEXT, hClipboardData)==NULL) { HANDLE hlocmem = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, sizeof(LCID)); PLCID plcid = (PLCID)GlobalLock(hlocmem); *plcid = lcid; GlobalUnlock(hlocmem); SetClipboardData(CF_LOCALE, static_cast<HANDLE>(plcid)); CloseClipboard(); return true; } } else { CloseClipboard(); return false; } } else { CloseClipboard(); return false; } } else { CloseClipboard(); return false; } CloseClipboard(); return false; } return false; }
AVSINLINE const CStringW Encoding::string2wstring(const CStringA &sLine, const unsigned int unCodePage) { const int nSize = MultiByteToWideChar( unCodePage, 0, sLine.GetString(), sLine.GetLength(), NULL, 0 ); wchar_t *sTemp = new wchar_t[nSize]; if ( !sTemp ) return _T(""); MultiByteToWideChar( unCodePage, 0, sLine.GetString(), sLine.GetLength(), sTemp, nSize ); CStringW sResult( sTemp ); delete []sTemp; return sResult; }
void CWinLogFile::Log(DWORD dwLogLevel, LPCWSTR lpszText) { if (!IsLevelEnabled(dwLogLevel)) return; if (!CAtlFile::m_h || INVALID_HANDLE_VALUE == CAtlFile::m_h) return; CStringA strLogLine; SYSTEMTIME localTime; ::GetLocalTime(&localTime); strLogLine.AppendFormat( "[%04hu-%02hu-%02hu %02hu:%02hu:%02hu.%03hu] ", localTime.wYear, localTime.wMonth, localTime.wDay, localTime.wHour, localTime.wMinute, localTime.wSecond, localTime.wMilliseconds); strLogLine.AppendFormat("[%lu] ", GetCurrentThreadId()); strLogLine.AppendFormat("[%s] ", GetLogLevelNameA(dwLogLevel)); strLogLine.Append(": "); strLogLine.Append(CW2A(lpszText)); CHAR chLast = strLogLine[strLogLine.GetLength() - 1]; if ('\r' != chLast && '\n' != chLast) { strLogLine.Append("\r\n"); } { CObjGuard guard(m_queueLock); HRESULT hr = CAtlFile::Write(strLogLine, strLogLine.GetLength()); } }
BOOL file_put_contents(LPCTSTR lpszFilename, LPCTSTR lpszBuffer) { CStringA strA; USES_CONVERSION; strA = CT2CA( lpszBuffer ); return file_put_contents(lpszFilename, (BYTE*)strA.GetString(), strA.GetLength()); }
bool CModDoc::CopyEnvelope(INSTRUMENTINDEX nIns, EnvelopeType nEnv) //----------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); HANDLE hCpy; DWORD dwMemSize; if ((nIns < 1) || (nIns > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nIns]) || (!pMainFrm)) return false; BeginWaitCursor(); const ModInstrument *pIns = m_SndFile.Instruments[nIns]; if(pIns == nullptr) return false; CStringA s; EnvelopeToString(s, pIns->GetEnvelope(nEnv)); dwMemSize = s.GetLength() + 1; if ((pMainFrm->OpenClipboard()) && ((hCpy = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, dwMemSize))!=NULL)) { EmptyClipboard(); LPBYTE p = (LPBYTE)GlobalLock(hCpy); if(p != nullptr) { memcpy(p, s.GetString(), dwMemSize); } GlobalUnlock(hCpy); SetClipboardData (CF_TEXT, (HANDLE)hCpy); CloseClipboard(); } EndWaitCursor(); return true; }
BOOL CUrlParser::AddOrSetParamValue(CStringA strName,CStringA strValue) { BOOL bRes = FALSE; if (strName.GetLength() == 0) { return bRes; } CStringA strTempValue; BOOL bFoundValue = GetParamValueByName(strName,strTempValue); if ( FALSE == bFoundValue ) { ParamNode node; node.strParamName = strName; node.strParamValue = strValue; int nCount = m_ParamList.size(); m_ParamList.push_back(node); bRes = ( m_ParamList.size() - nCount ) == 1; } else { bRes = SetParamValueByName(strName,strValue); } return bRes; }
CStringA CUrlParser::BuildPath() { CStringA strNewUrl; strNewUrl = m_strPath; if (m_ParamList.size() > 0) { strNewUrl+="?"; } for (ParamListPtr it = m_ParamList.begin();it!=m_ParamList.end();it++) { if (it->strParamValue.GetLength() == 0) { strNewUrl+=it->strParamName+"&"; } else { strNewUrl+=it->strParamName+"="+it->strParamValue+"&"; } } strNewUrl.Delete(strNewUrl.GetLength()-1); return strNewUrl; }
void KadGetKeywordHash(const CStringA& rstrKeywordA, Kademlia::CUInt128* pKadID) { CMD4 md4; md4.Add((byte*)(LPCSTR)rstrKeywordA, rstrKeywordA.GetLength()); md4.Finish(); pKadID->setValueBE(md4.GetHash()); }
bool CIPFilter::ParseFilterLine2(const CStringA& sbuffer, uint32& ip1, uint32& ip2, UINT& level, CStringA& desc) const { int iPos = sbuffer.ReverseFind(':'); if (iPos < 0) return false; desc = sbuffer.Left(iPos); desc.Replace("PGIPDB", ""); desc.Trim(); CStringA strIPRange = sbuffer.Mid(iPos + 1, sbuffer.GetLength() - iPos); UINT u1, u2, u3, u4, u5, u6, u7, u8; if (sscanf(strIPRange, "%u.%u.%u.%u - %u.%u.%u.%u", &u1, &u2, &u3, &u4, &u5, &u6, &u7, &u8) != 8) return false; ((BYTE*)&ip1)[0] = (BYTE)u4; ((BYTE*)&ip1)[1] = (BYTE)u3; ((BYTE*)&ip1)[2] = (BYTE)u2; ((BYTE*)&ip1)[3] = (BYTE)u1; ((BYTE*)&ip2)[0] = (BYTE)u8; ((BYTE*)&ip2)[1] = (BYTE)u7; ((BYTE*)&ip2)[2] = (BYTE)u6; ((BYTE*)&ip2)[3] = (BYTE)u5; level = DFLT_FILTER_LEVEL; return true; }
int CGitIgnoreItem::IsPathIgnored(const CStringA& patha, const char* base, int& type) { if (!m_pExcludeList) return -1; // error or undecided return git_check_excluded_1(patha, patha.GetLength(), base, &type, m_pExcludeList); }
BOOL CCookie::AdjustPath(CStringA& strPath, LPCSTR lpszDefaultPath) { if(strPath.IsEmpty() && lpszDefaultPath) strPath = lpszDefaultPath; int iLength = strPath.GetLength(); if(iLength == 0) return FALSE; if(strPath.GetAt(iLength - 1) != COOKIE_PATH_SEP_CHAR) { int iPos = strPath.ReverseFind(COOKIE_PATH_SEP_CHAR); if(iPos >= 0) strPath = strPath.Left(iPos + 1); else strPath.Empty(); } if(!strPath.IsEmpty() && strPath.GetAt(0) != COOKIE_PATH_SEP_CHAR) strPath.Insert(0, COOKIE_PATH_SEP_CHAR); return !strPath.IsEmpty(); }
CString OptUtf8ToStr(const CStringA& rastr) { CStringW wstr; int iMaxWideStrLen = rastr.GetLength(); LPWSTR pwsz = wstr.GetBuffer(iMaxWideStrLen); int iWideChars = utf8towc(rastr, rastr.GetLength(), pwsz, iMaxWideStrLen); if (iWideChars <= 0) { // invalid UTF8 string... wstr.ReleaseBuffer(0); wstr = rastr; // convert with local codepage } else wstr.ReleaseBuffer(iWideChars); return wstr; // just return the string }
bool CTGitPathList::WriteToFile(const CString& sFilename, bool bANSI /* = false */) const { try { if (bANSI) { CStdioFile file(sFilename, CFile::typeText | CFile::modeReadWrite | CFile::modeCreate); PathVector::const_iterator it; for(it = m_paths.begin(); it != m_paths.end(); ++it) { CStringA line = CStringA(it->GetGitPathString()) + '\n'; file.Write(line, line.GetLength()); } file.Close(); } else { CStdioFile file(sFilename, CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate); PathVector::const_iterator it; for(it = m_paths.begin(); it != m_paths.end(); ++it) { file.WriteString(it->GetGitPathString()+_T("\n")); } file.Close(); } } catch (CFileException* pE) { CTraceToOutputDebugString::Instance()(__FUNCTION__ ": CFileException in writing temp file\n"); pE->Delete(); return false; } return true; }
BOOL ProcessString(CStringA sID, CStringA sString) { const int len = sString.GetLength(); if ( sString.GetAt( 0 ) != '\"' || sString.GetAt( len - 1 ) != '\"' ) { _tprintf( _T("Error: Invalid string format \"%hs\"\n"), sString ); return FALSE; } sString = sString.Mid( 1, len - 2 ); UINT nID = 0; if ( ! g_oIDs.Lookup( sID, nID ) ) { _tprintf( _T("Warning: Unknown ID %hs \"%hs\"\n"), sID, sString ); return TRUE; } CSSPair sFoo; if ( g_oStrings.Lookup( nID, sFoo ) ) { _tprintf( _T("Error: Duplicate ID %hs \"%hs\"\n"), sID, sString ); return FALSE; } g_oStrings.SetAt( nID, CSSPair( sString, sID ) ); return TRUE; }
CStringA CBase64::Encode( IN const char* szEncoding, IN int nSize ) { CStringA sOutput = ""; int nNumBits = 6; UINT nDigit; int lp = 0; int count = 0; ASSERT( szEncoding != NULL ); if( szEncoding == NULL ) return sOutput; m_szInput = szEncoding; m_nInputSize = nSize; m_nBitsRemaining = 0; nDigit = read_bits( nNumBits, &nNumBits, lp ); while( nNumBits > 0 ) { sOutput += m_sBase64Alphabet[ (int)nDigit ]; nDigit = read_bits( nNumBits, &nNumBits, lp ); count++; if(count % 80 == 0) sOutput += '\n'; } // Pad with '=' as per RFC 1521 while( sOutput.GetLength() % 4 != 0 ) { sOutput += '='; } return sOutput; }