Diacritics get stripped out of my capitalization function
I have a very simple capitalization program that helps me auto-capitalize text files. It operates from a capitalization dictionary which is also a text file. The capitalization dictionary consists of nothing more than words that are always capitalized a certain way, separated by line breaks. So, for example, if the capitalization dictionary consists of the following:
and the string to be processed is:
i watched "napoleon dynamite" in french on my ipad
the output after processing will be:
I watched "Napoleon Dynamite" in French on my iPad
However, for some reason I cannot figure out, the program strips out (i.e., deletes) any character that has a diacritic. So if I add to my capitalization dictionary the word:
and the string is:
i watched "napoleon dynamite" in french on my ipad with my friend napoléon
what I end up with is:
I watched "Napoleon Dynamite" in French on my iPad with my friend napolon
Obviously, this is not desired. Can anyone help me figure out what the fix might be, to make sure that letters with diacritics are treated properly rather than being deleted? I think it might have something to do with the ToLower function...
Re: Diacritics get stripped out of my capitalization function
Originally Posted by Robert K S
I think it might have something to do with the ToLower function...
You can find out for sure by setting a break point and step through the code in the debugger. Look at the str before the ToLower() method gets called and then afterward.
If it is the ToLower removing the diacritic letters, then you may want to not use that function.
Why not use the split method using a space as the delimiter, then just check if the leading character is capitalized and if it isn't make it a capital.
Also, check out the StringBuilder class, because you can access individual characters and make in place edits (as opposed to a new string object getting create each time you call a string member function).