Why does ToTitleCase not work if the case is already in upper case?

T

titan nyquist

Why does ToTitleCase not work if the case is already in upper case?

I have to make my string lowercase, first, before I pass to to
ToTitleCase to have it work.

Titan
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

titan said:
Why does ToTitleCase not work if the case is already in upper case?

I have to make my string lowercase, first, before I pass to to
ToTitleCase to have it work.

Titan

That is the way that the function is supposed to work:

"Generally, title casing converts the first character of a word to
uppercase and the rest of the characters to lowercase. However, a word
that is entirely uppercase, such as an acronym, is not converted."
 
P

Peter Duniho

Why does ToTitleCase not work if the case is already in upper case?

So that acronyms and abbreviations are not incorrectly converted to lower
case, as the documentation explains.
I have to make my string lowercase, first, before I pass to to
ToTitleCase to have it work.

If you know that the string is all upper-case, this is probably a fine
solution. Beware, however, of accidently converting to lower-case letters
that should be upper-case.

Pete
 
T

titan nyquist

Thanks. That makes it tough... as some of my strings are all UPPER
CASE when they shouldn't be. It's hard to differentiate between what
should be made title case and what shouldn't.

Titan.
 
P

Peter Duniho

Thanks. That makes it tough... as some of my strings are all UPPER
CASE when they shouldn't be. It's hard to differentiate between what
should be made title case and what shouldn't.

Yup. A strictly typographical algorithm is going to need human
intervention to avoid doing it wrong at least some of the time, since
human languages don't encode that information when letter case is absent.
Alternatively, you could just accept that the results are going to be
wrong some of the time and implement the solution in a way that gets it
right the greatest amount of time (so if you know, for example, that you
get strings that are all upper case much more often than you get strings
that have acronyms or other abbreviations in them, you can go ahead and do
what you're doing).

Other than that, you could of course apply some sort of dictionary
approach, where you convert the string to lower case one word at a time
and actually look at the words in the string to see whether it's safe to
convert them to lower case or not. This is much more complicated, of
course, especially if performance is an issue. But it would have the
advantage of being more accurate.

It just depends on how important it is to get it right 100% of the time.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top