验证假名输入 [英] Validating Kana Input

查看:49
本文介绍了验证假名输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个允许用户输入日语字符的应用程序.我试图提出一种方法来确定用户输入的内容是日语假名(平假名,片假名还是汉字).

I am working on an application that allows users to input Japanese language characters. I am trying to come up with a way to determine whether the user's input is a Japanese kana (hiragana, katakana, or kanji).

应用程序中的某些字段不适合输入拉丁文字,我需要一种方法来将某些字段限制为仅汉字或仅片假名等.

There are certain fields in the application where entering Latin text would be inappropriate and I need a way to limit certain fields to kanji-only, or katakana-only, etc.

该项目使用UTF-8编码.我不希望接受JIS或Shift-JIS输入.

The project uses UTF-8 encoding. I don't expect to accept JIS or Shift-JIS input.

想法?

推荐答案

听起来您基本上只需要检查每个Unicode字符是否在特定范围内. Unicode代码图表应该是一个很好的起点.

It sounds like you basically need to just check whether each Unicode character is within a particular range. The Unicode code charts should be a good starting point.

如果您使用的是.NET,我的 MiscUtil 库具有Unicode范围支持-这是原始的,但应该可以完成.我现在没有消息来源,但是如果有帮助的话,稍后将通过示例更新此帖子.

If you're using .NET, my MiscUtil library has some Unicode range support - it's primitive, but it should do the job. I don't have the source to hand right now, but will update this post with an example later if it would be helpful.

这篇关于验证假名输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆