RE: [PHP-I18N] detecting katakana vs hiragana

From: Date: Fri, 28 Feb 2003 13:43:38 +0000
Subject: RE: [PHP-I18N] detecting katakana vs hiragana
References: 1  Groups: php.i18n 
Request: Send a blank email to php-i18n+get-473@lists.php.net to get a copy of this message
I haven't tried the mb_ereg solution yet, but I thought of doing something with mb_convert_kana() Here's a little example script. I try it, but nothing gets converted at all! (I have mb functions Enabled and am using PHP 4.3.0 on a Window XP system). Why doesn’t this work? Simon <html> <head> <meta http-equiv="Content-Type" content="Text/Html; Charset=UTF-8"> <title>hira2kata</title> </head> <body> <?php $str="わたしわ"; // watashi echo $str."<br>"; $str = mb_convert_kana($str, "c"); echo $str."<br>"; $str = mb_convert_kana($str, "C"); echo $str; ?> </body> </html> You can accomplish it by converting any hiragana / katakana mixture to either hiragana or katakana characters with mb_convert_kana() and then comparing it with the original. Also try mb_ereg_* functions that allows localised characters to be used in character classes. Moriyoshi

« previous php.i18n (#473) next »