tag editor: fix CapitalizeFirstLetters

This commit is contained in:
Andrzej Rybczak
2012-09-08 15:05:36 +02:00
parent 8fb88b7181
commit 1eecc0aa0b

View File

@@ -1103,17 +1103,15 @@ namespace {//
std::string CapitalizeFirstLetters(const std::string &s) std::string CapitalizeFirstLetters(const std::string &s)
{ {
if (s.empty()) std::wstring ws = ToWString(s);
return ""; wchar_t prev = 0;
std::string result = s; for (auto it = ws.begin(); it != ws.end(); ++it)
if (!isspace(result[0]))
result[0] = toupper(result[0]);
for (std::string::iterator it = result.begin()+1; it != result.end(); ++it)
{ {
if (!isspace(*it) && isspace(*(it-1)) && *(it-1) != '\'') if (!iswalpha(prev) && prev != L'\'')
*it = toupper(*it); *it = towupper(*it);
prev = *it;
} }
return result; return ToString(ws);
} }
void CapitalizeFirstLetters(MPD::MutableSong &s) void CapitalizeFirstLetters(MPD::MutableSong &s)