简体   繁体   中英

Turn Capitalize text into Lower case with accent in String with Java

In a string, is there a way to find and turn a capitalized word that should contains accent into its lowercase form with accent in Java. This is an example.

 string = "Bonjour ceci est un PRELEVEMENT de votre banque CIC."
 result = "Bonjour ceci est un prélèvement de votre banque CIC."

Is there an autocorrect function that could fix this ? I'd like to avoid using a dictionary with accentued words.

There is no way to do this without a dictionary. That E in PRELEVEMENT is just an E, not a special character with meaning 'capitalized e-acute with hidden acute' (you can check the unicode tables; there's no such thing). It's just.. E - unicode symbol 69. No way to get to é or è from that without looking 'prelevement' up in some sort of dictionary or other mapping.

Note, however, that the android device, assuming the french dictionary has been selected by the owner of the device, ships with a spell checker, and that checker can be accessed directly by your api via the text services API . I would assume tossing PRELEVEMENT through that spell checker will get you prélèvement. Make sure you pass Locale.FR for the 'locale' parameter when creating the session.

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