检查 iPhone 上键盘输入的 ASCII 兼容性
当用户点击键盘时,我需要知道输入符号是否属于 ASCII 调色板,否则将其剥离。
那么我需要在
-(BOOL) textField: (UITextField*) textField shouldChangeCharactersInRange: (NSRange) range replacementString: (NSString*) string
方法中做什么来检查输入字符?
目前,当用户使用(例如)俄语输入时,我从输入字符串中获取 ASCII 字符:
const char* want_strip_not_ascii_chars = [string UTF8string];
When user taps on keyboard, I need to know does the input symbol belong to ASCII palette, and strip it otherwise.
So what I need to do in
-(BOOL) textField: (UITextField*) textField shouldChangeCharactersInRange: (NSRange) range replacementString: (NSString*) string
method to check input character?
At current moment I get an ASCII characters from input string when user types with (for example) Russian language:
const char* want_strip_not_ascii_chars = [string UTF8string];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下内容将满足您的要求:
尽管如此,请考虑这将阻止使用非 ASCII 键盘的用户使用您的字段。
The following will give you what you are asking for:
Though do please consider that this will prevent users with non-ASCII keyboards from using your field.