CString CRelatedSearch::Tokenise(LPCTSTR psz) { int nChars = 0; CString str, strTemp(psz); // remove diacritics; supported for NT systems only if ( theApp.m_bNT ) { int nSource = FoldString( MAP_COMPOSITE, psz, -1, NULL, 0 ); //_tcslen( psz ); FoldString( MAP_COMPOSITE, psz, -1, strTemp.GetBuffer( nSource ), nSource ); strTemp.ReleaseBuffer( nSource ); psz = strTemp.GetBuffer( nSource ); } int nLastPoint = strTemp.ReverseFind( '.' ); if ( nLastPoint > 0 ) nLastPoint = strTemp.GetLength() - nLastPoint - 1; for ( ; *psz ; psz++ ) { if ( *psz == '.' && _tcslen( psz ) == nLastPoint ) { break; } else if ( _istalnum( *psz ) ) { str += *psz; nChars ++; } else if ( nChars > 1 && !( *psz >= 0x02B0 && *psz <= 0x036F ) ) { str += ' '; nChars = 0; } else if ( nChars == 1 && !( *psz >= 0x02B0 && *psz <= 0x036F ) ) { str = str.Left( str.GetLength() - 1 ); nChars = 0; } } return str; }
int ceWtoI( IN WCHAR const *string, OUT BOOL *pfValid) { HRESULT hr; WCHAR szBuf[16]; WCHAR *szTmp = szBuf; int cTmp = ARRAYSIZE(szBuf); int i = 0; WCHAR const *pwsz; BOOL fSawDigit = FALSE; if (pfValid == NULL) { hr = E_POINTER; _JumpError(hr, error, "NULLPARAM"); } *pfValid = FALSE; assert(NULL != pfValid); cTmp = FoldString( MAP_FOLDDIGITS, string, -1, szTmp, cTmp); if (cTmp == 0) { hr = ceHLastError(); if (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) == hr) { hr = S_OK; cTmp = FoldString( MAP_FOLDDIGITS, string, -1, NULL, 0); szTmp = (WCHAR*)LocalAlloc(LMEM_FIXED, cTmp*sizeof(WCHAR)); if (NULL == szTmp) { hr = E_OUTOFMEMORY; _JumpError(hr, error, "LocalAlloc"); } cTmp = FoldString( MAP_FOLDDIGITS, string, -1, szTmp, cTmp); if (cTmp == 0) hr = ceHLastError(); } _JumpIfError(hr, error, "FoldString"); } pwsz = szTmp; while (iswspace(*pwsz)) { pwsz++; } while (iswdigit(*pwsz)) { fSawDigit = TRUE; pwsz++; } while (iswspace(*pwsz)) { pwsz++; } if (L'\0' == *pwsz) { *pfValid = fSawDigit; } i = _wtoi(szTmp); error: if (szTmp && (szTmp != szBuf)) LocalFree(szTmp); return i; }