The end of the url is the entryid, but to save space we now encode it.
The decoding algorythmn looks like this:
void CEntryId::FromString(__in CString &strEIDU) {
//----------- Decode with YEncode like algorythm ------- // decode using pseudo YENC encoding, everything is shifted up by 0x30 starting it at the '0' letter. // Things that wrap have an escape '!' followed by a 0x60 to put it back up to '0' letter range LPCWSTR pszSrc = strEIDU;
// the first WCHAR is the length of the buffer m_cBytes = *pszSrc++ - 0x30;
// add 2 to the size of the buffer since we assume an odd buffer size could lead to a byte being assigned after // the size of the buffer. This is a side-effect of the way we are encoding the buffer AllocateBuffer(m_cBytes+2);
ATLASSERT(m_pEntryId != NULL);
if (m_pEntryId != NULL) { // output is to allocated buffer LPWSTR pszDest = (LPWSTR)m_pEntryId;
// for each WCHAR in unicode string, int Len = strEIDU.GetLength();
// (start at position 1 because the zeroth WCHAR is actually the # of bytes in EID) for(int i=1; i < Len; i++) { int offset = 0x30;
// if it's an escaped char if (*pszSrc == L'!') { // skip escape char pszSrc++; i++;
// offset is now 60 offset = 0x60; } // restore current WCHAR *pszDest++ = (WCHAR)(((ULONG)*pszSrc + 0x10000) % 0x10000) - offset;
// advance to next position pszSrc++;
ATLASSERT((DWORD)((LPBYTE)pszDest - (LPBYTE)m_pEntryId) <= (DWORD)(m_cBytes+2)); } } }
Dev Lead MSN Deskop Search |