From 1eecc0aa0b21add052fa4604d4ed0fb3531859dc Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 8 Sep 2012 15:05:36 +0200 Subject: [PATCH] tag editor: fix CapitalizeFirstLetters --- src/tag_editor.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index e6f1d04e..9ceb38ec 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -1103,17 +1103,15 @@ namespace {// std::string CapitalizeFirstLetters(const std::string &s) { - if (s.empty()) - return ""; - std::string result = s; - if (!isspace(result[0])) - result[0] = toupper(result[0]); - for (std::string::iterator it = result.begin()+1; it != result.end(); ++it) + std::wstring ws = ToWString(s); + wchar_t prev = 0; + for (auto it = ws.begin(); it != ws.end(); ++it) { - if (!isspace(*it) && isspace(*(it-1)) && *(it-1) != '\'') - *it = toupper(*it); + if (!iswalpha(prev) && prev != L'\'') + *it = towupper(*it); + prev = *it; } - return result; + return ToString(ws); } void CapitalizeFirstLetters(MPD::MutableSong &s)