简体   繁体   中英

How to capitalize a French word with characters that are HTML-encoded?

I have strings in my database that are in all-caps and I need these strings to be in title case on the client side.

I am using

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(string);

to do this but it doesn't work for French characters such as

ê

which is being capitalized even though it is in the middle of the word.

The result of

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(l'hêtrière);

is: L'hÊTriÈRe and this is not what I want.

I was using regular expressions before but it did not solve this issue either. Any ideas or a general direction would be greatly appreciated.

You have to decode the html string before using ToTitleCase.

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(HttpUtility.HtmlDecode("l'hêtrière").ToLower());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM