Titlecase bug?

When using Titlecase, it ignores words that don’t start with a letter.
for instance,

Var a As String = "”dark side of the moon”"
a = a.Titlecase

The result is ”dark Side Of The Moon” - it should be "Dark Side Of The Moon”

Single or double quotes, brackets, and other characters in front prevent words from being capitalized.

i bet the function checks only full words, eg split by spaces.

Maybe you can ReplaceAll("""", “”" “) before the titlecase then it will do all the words.
Afterwards you can after the titlecase replaceAll(”"" “, “””") this reverts back the changed string.

I wrote a routine to fix it for me. It splits text by spaces, and then checks the first character of each word for anything that’s not a letter. If it starts with a non-letter character it passes it to a function that searches for and capitalizes the first letter.

Then it splits the text by EndOfLine and checks the first word of each sentence in case one starts with a character that’s not a letter, and passes it to the same function if it does.

I would not want to do a whole novel this way, but for sentences and short paragraphs it works.

Bug

https://tracker.xojo.com/xojoinc/xojo/-/issues/18449
https://tracker.xojo.com/xojoinc/xojo/-/issues/28024

Maybe someone at Xojo can reopen 28024 and people can throw some :+1: on it.

4 Likes