自动为字母添加重音
我有几个按钮,可以轻松地为字母添加重音符号,例如,可以通过按 ´
按钮然后输入 e 来输入
。é
有没有简单的方法可以为任何字母添加特定的重音,这样我就不必为每个可以有这种重音的字母创建数十个 if 语句?字母的 Unicode 编号和带重音符号的字母之间是否存在联系?
任何建议将不胜感激,法比安
I have a few buttons that should make it simple to add accents to letters so that for instance é
can be typed by pressing the ´
button and then entering an e
.
Is there any easy way to add a certain accent to any letter, so that I don't have to create dozens of if statements for every letter that can have this accent? Is there maybe a link between the Unicode number of the letter and the letter with an accent?
Any suggestions would be appreciated, Fabian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为您可以在这里应用 unicode 数学的简单组合,但是您可以通过创建查找字典来使您的过程更加高效。
使键成为字母+重音符号,然后将其存储在类中的字典中
然后,使用用户按下的字母,并使用重音按钮生成后半部分,构造键并查看它在字典里。这样,您就可以避免所有 if 语句。请记住在
init
或其他地方构建字典。I don't think there is a simple combination of unicode math that you can apply here, but you can make your procedure much more efficient by making a lookup dictionary.
make the key be the letter + a symbol for the accent, then store it in a dictionary in your class
Then later, using the letter pressed by the user, and using your accent button to generate the second half, construct the key and look it up in the dictionary. This way, you avoid all of the if statements. Remember to construct your dictionary in
init
or elsewhere.