Hi,
I use the stl features to deal with string conversions, especially facets. Now, I am faced with the task to lower a string except its first letter. Please note that I am dealing with multi-byte characters and so I cannot simply replace the first character of the string with its original after lowering it. Here is my code for lowering a string entirely:
std::string lower_string ( const std::string& a_string, const std::locale& a_locale )
{
std::string result;
char *p = (char*) alloca ( a_string.size() + 1 );
memcpy ( p, a_string.c_str (), a_string.size() + 1);
std::use_facet< std::ctype<char> > ( a_locale ).tolower ( p, p + a_string.length () );
result.assign(p);
return result;
}
Has anyone an idea how to avoid the conversion of the first (probably) multi-byte character in a c++ way? Or a way to subsequently upper the first character?
Many thanks in advance,
Kay