Re: Japanese character validation
| From: | - Edwin - | Date: | Fri, 07 Nov 2003 17:20:00 +0000 |
| Subject: | Re: Japanese character validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168875@lists.php.net to get a copy of this message | ||
Hi,
On 2003.11.8, at 00:42 Asia/Tokyo, Lew Mark-Andrews wrote:
Howdy,True. But...It's actually quite common for forms here in Japan (both online and paper) where the user is requested to give the phonetic reading in Hiragana or Katakana for their Kanji name. (Especially the first name where there can be a lot of latitude on the reading even if the Kanji used has other more conventional readings. Likewise for some uncommon place names.)I have accept input from the user and check if the input is japanese character only, for example : If name is accepted , I need to check if its any of the Hiragana, Katakana or Kanji.Hmm... why would you like to do that? I've never really seen the need for that.
Online, it can also be handy where you want to disallow the use of and catch and filter numbers or symbols that may also have double-byte equivalents, and instead use only the Hankaku ASCII forms, though these can usually be validated more directly by an A - Z, 0 - 9, etc. regular expression.Well, just like you said, Hankaku can easily be validated. But, how and WHY would you want to validate if a certain field is Kanji, katakana, or hiragana? And limit certain fields to each of those? Think what would happen if you only accept only Kanji in a certain field. Here are some issues you'd face: 1. Not all Japanese have Kanjis in their names. 2. Not all who can read Japanese have Japanese names. ;)
We currently do this to validate our form inputs on the client side using Javascript functions before accepting the inputs serverside. When I have time, I'll look into what's possible with the mb_ereg/mb_regex functions. Umesh, if you'd like a copy of our Javascript functions, please contact me offlist.Hmm... interesting but whether you validate with Javascript and/or PHP, you'll face the same problem I mentioned above. Besides, there are some issues (for example with Shift_JIS) that "bothers" (with no easy "solution") even members of the Japanese PHP Group ML. (Like the recent thread [PHP-users 18803] on http://www.php.gr.jp/ or http://ns1.php.gr.jp/mailman/listinfo/php-users mentioned about the SJIS trouble.) There was actually a similar topic on validation (in the Japanese ML) but there is no easy solution esp. about those "platform (read Windows) independent characters". This was also mentioned by the OP ("numbers inside circles" character problem). Well, I'm satisfied (for now) with the mb_ functions... - E - __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/