M
Matthias
Hello,
I am missing certain functionality of std::string, so I am currently
writing some helper functions which operate on strings. On of them is as
follows (it's actually two functions):
inline char to_lower ( char c )
{
if( c>=65 && c<=90 ) // A-Z
return c += 32;
return c;
}
inline void str_to_lower ( std::string& source )
{
std::transform( source.begin(), source.end(), source.begin(),
to_lower );
}
My question concerns the function to_lower:
Is this portable? I looked at an ASCII table, and recognized that I can
convert uppercase letters to lowercase by adding 32. However, I have no
idea if this will work for other character tables.
I am missing certain functionality of std::string, so I am currently
writing some helper functions which operate on strings. On of them is as
follows (it's actually two functions):
inline char to_lower ( char c )
{
if( c>=65 && c<=90 ) // A-Z
return c += 32;
return c;
}
inline void str_to_lower ( std::string& source )
{
std::transform( source.begin(), source.end(), source.begin(),
to_lower );
}
My question concerns the function to_lower:
Is this portable? I looked at an ASCII table, and recognized that I can
convert uppercase letters to lowercase by adding 32. However, I have no
idea if this will work for other character tables.