简体   繁体   English

使用 Java 将字符串中的带重音的大写文本转换为小写

[英]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.在一个字符串中,有没有办法在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).EPRELEVEMENT只是一个E,而不是特殊字符与意为“大写E-急性与隐藏急性”(你可以检查Unicode表,有没有这样的事情)。 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.这只是.. E - unicode 符号 69. 没有办法从那得到 é 或 è 而不在某种字典或其他映射中查找“prelevement”。

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 .但是请注意,android 设备(假设设备所有者已选择法语词典)附带了拼写检查器,并且您的 api 可以通过文本服务API直接访问该检查器。 I would assume tossing PRELEVEMENT through that spell checker will get you prélèvement.我认为通过拼写检查器抛出 PRELEVEMENT 会让你获得 prélèvement。 Make sure you pass Locale.FR for the 'locale' parameter when creating the session.确保在创建会话时为 'locale' 参数传递Locale.FR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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