So I created my own simple toTitleCase function… but it’s really only good for English… since it just capitalizes the first character of each word…
String toTitleCase (const String& theString)
{
String szTitleString;
bool bFlag = false;
juce_wchar c;
if (CharacterFunctions::isLetter (theString[0]))
c = CharacterFunctions::toUpperCase (theString[0]);
else
c = theString[0];
szTitleString += c;
for (int i = 1; i < theString.length(); ++i)
{
c = theString[i];
if (! CharacterFunctions::isWhitespace (c) && CharacterFunctions::isLetter (c))
{
if (bFlag)
c = CharacterFunctions::toUpperCase (c);
}
if (CharacterFunctions::isWhitespace (c))
bFlag = true;
else
bFlag = false;
szTitleString += c;
}
return szTitleString;
}
Checking out Microsoft’s page on their TextInfo.ToTitleCase Method they also have similar issues with their algorithm. Since I’m linguistically challenged, I was wondering if anyone who speaks a language other than English would care to list the words or the rules which would apply to globalize this function… for (any) other languages?
If you check out the “Remarks” on the Microsoft page: https://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase(v=vs.110).aspx you’ll see what I’m talking about. (Sorry tried using the BBCode url keyword to fix the link, but it doesn’t seem to work correctly).
Thanks,
Rail