src/Generic/common/UnicodeUtil.cpp
/* true if name2 is the same as name1 or a non-trivial sub name of name1 */
true if name2 is the same as name1 or a non-trivial sub name of name1
true if name2 is the same as name1 or a non - trivial sub name of name1
bool UnicodeUtil::nonTrivialSubName(const std::wstring & name1, const std::wstring & name2){
	if (name2.length() > name1.length()) return false;
	if (name1.find(L' ') == std::wstring::npos) return false;
	std::wstring low1 = name1;
	std::transform(low1.begin(), low1.end(), low1.begin(), towlower);
	std::wstring low2 = name2;
	std::transform(low2.begin(), low2.end(), low2.begin(), towlower);
	if (low2 == L"al" || low2 == L"de" || low2 == L"bin" )
		return false;
	std::wstring padN2 = L' ' + low2 + L' ';
	std::wstring padN1 = L' ' + low1 + L' ';
	size_t pN2Len = padN2.length();
	size_t pN1Len = padN1.length();
	size_t n2InN1 = padN1.find(padN2);
	if (n2InN1 == 0  || n2InN1 == (pN1Len - pN2Len)){
		return true;
	}
	return false;
}
bool UnicodeUtil :: nonTrivialSubName ( const std :: wstring & name1 , const std :: wstring & name2 ) { if ( name2 . length ( ) > name1 . length ( ) ) return false ; if ( name1 . find ( L' ' ) == std :: wstring :: npos ) return false ; std :: wstring low1 = name1 ; std :: transform ( low1 . begin ( ) , low1 . end ( ) , low1 . begin ( ) , towlower ) ; std :: wstring low2 = name2 ; std :: transform ( low2 . begin ( ) , low2 . end ( ) , low2 . begin ( ) , towlower ) ; if ( low2 == L" " || low2 == L" " || low2 == L" " ) return false ; std :: wstring padN2 = L' ' + low2 + L' ' ; std :: wstring padN1 = L' ' + low1 + L' ' ; size_t pN2Len = padN2 . length ( ) ; size_t pN1Len = padN1 . length ( ) ; size_t n2InN1 = padN1 . find ( padN2 ) ; if ( n2InN1 == 0 || n2InN1 == ( pN1Len - pN2Len ) ) { return true ; } return false ; }
true if name2 is the same as name1 or a non-trivial sub name of name1
true if name2 is the same as name1 or a non - trivial sub name of name1
// check for trivial names -- make more efficient if list gets big
 // covered by length test at start of method
 //if (n2InN1 == std::wstring::npos) return false;
 // name1 has at least one blank in it and its token sequence
 // includes token sequence of name2
 // with the match pinned at first or last of the bigger name.
 // So we think name1 is of type <First <Middle>* Last> and 
 // name2 is of type <First <Middle>*> or type <<Middle>* Last>
