Titlecase function

Hoping Julian add’s to the String class…

(Useful for CamelCase)

const String String::toTitleCase () const throw()
{
	
	String result (*this);
	result.dupeInternalIfMultiplyReferenced();
	tchar* t = result.text->text;
	
	bool wordStart=true;
	while (*t != 0)
	{
		
		if (CharacterFunctions::isWhitespace(*t) || !CharacterFunctions::isLetterOrDigit(*t))
		{
			wordStart = true;
		}
		else if (wordStart == true)
		{
			CharacterFunctions::toUpperCase(t);
			wordStart = false;
		}
		else
		{
			CharacterFunctions::toLowerCase(t);
		}
		++t;
	}
	
	return result;
}

Can’t quite decide if that’s a good candidate for the String class or not… It feels a bit too language-specific really…

True… but toUppercase and toLowercase are in there!

:wink: