M
Mosfet
Hi,
what is the most efficient way of doing a case insensitive comparison ?
I am trying to write a universal String class and I am stuck with the
case insensitive part :
TCHAR is a char in MultiByte String env (MBCS)
and wchar_t if UNICODE
#if defined(WIN32) || defined(UNDER_CE)
typedef std::basic_string<TCHAR, std::char_traits<TCHAR>,
std::allocator<TCHAR> > tstring;
#else
#endif
#endif
class String : public Object
{
private:
tstring m_str;
public:
String(){}
String(LPCTSTR lpsz)
{
m_str = lpsz;
}
String(tstring str)
{
m_str = str;
}
// Comparison
int Compare( LPCTSTR psz ) const
{
return m_str.compare(psz);
}
int CompareNoCase( LPCTSTR psz ) const
{
???
}
// Convert the string to lowercase
String& MakeLower( LPCTSTR psz )
{
std::transform(m_str.begin(), m_str.end(), m_str.begin(), tolower);
return *this;
}
}
what is the most efficient way of doing a case insensitive comparison ?
I am trying to write a universal String class and I am stuck with the
case insensitive part :
TCHAR is a char in MultiByte String env (MBCS)
and wchar_t if UNICODE
#if defined(WIN32) || defined(UNDER_CE)
typedef std::basic_string<TCHAR, std::char_traits<TCHAR>,
std::allocator<TCHAR> > tstring;
#else
#endif
#endif
class String : public Object
{
private:
tstring m_str;
public:
String(){}
String(LPCTSTR lpsz)
{
m_str = lpsz;
}
String(tstring str)
{
m_str = str;
}
// Comparison
int Compare( LPCTSTR psz ) const
{
return m_str.compare(psz);
}
int CompareNoCase( LPCTSTR psz ) const
{
???
}
// Convert the string to lowercase
String& MakeLower( LPCTSTR psz )
{
std::transform(m_str.begin(), m_str.end(), m_str.begin(), tolower);
return *this;
}
}