|
mb_convert_kana
Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
(PHP 4 >= 4.0.6, PHP 5)
mb_convert_kana() performs "han-kaku" - "zen-kaku" conversion for string str. It returns converted string. This function is only useful for Japanese.
option is conversion option. Default value
is encoding is character encoding. If it is omitted, internal character encoding is used.
Specify with combination of following options. Default
value is Table 179. Applicable Conversion Options
Example 1393. mb_convert_kana() example<?php Code Examples / Notes » mb_convert_kanadn
It seems that mb_convert_kana() doesn't convert symbols such as ' (single quoatation). It affected my program when I insert data into database. So, I've found 2 ways to solve this. 1) Use Javascript to convert those non-supported symbols before sending query string to your php page. 2) Use php function, str_replace $str, to replace those non-supported symbols. For example, $str = str_replace("'", "", $str); where the first single quot is half-width(han kaku), and the second one is full-width(zen kaku). d
I didn't find Japanese sorting function. (mb_sort_kana or something) Only SJIS encoding treats hankaku kata kana, I can't post here copy & paste version script. I'm sorry... You will replace comments with appropriate japanese string, and write exception handlings between lines as you like. <?php mb_internal_encoding("SJIS"); $moji = /*"aiueo...wawon -?.," <- serialized hankaku kata kana 50 on hyou goes here*/; $moji .= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz0123456789"; for($i = 0; isset($moji[$i]); $i++){ $pittan[$moji[$i]] = $i; } function cmp($a, $b) { if ($a == $b) { return 0; } return iter(mb_convert_kana($a, "askh") ,mb_convert_kana($b, "askh"), 0); } function iter($a, $b, $i){ global $pittan; if(!isset($a[$i]) || !isset($b[$i])){ return (isset($b[$i]))? -1 : 1; } if ($pittan[$a[$i]] == $pittan[$b[$i]]){ return iter($a, $b, ++$i); } return (($pittan[$a[$i]]) < ($pittan[$b[$i]]))? -1 : 1; } echo "<pre>"; $arr = array(/*some japanese array here*/); usort($arr, "cmp"); var_dump($arr); ?> |
Change Languagemb_check_encoding mb_convert_case mb_convert_encoding mb_convert_kana mb_convert_variables mb_decode_mimeheader mb_decode_numericentity mb_detect_encoding mb_detect_order mb_encode_mimeheader mb_encode_numericentity mb_ereg_match mb_ereg_replace mb_ereg_search_getpos mb_ereg_search_getregs mb_ereg_search_init mb_ereg_search_pos mb_ereg_search_regs mb_ereg_search_setpos mb_ereg_search mb_ereg mb_eregi_replace mb_eregi mb_get_info mb_http_input mb_http_output mb_internal_encoding mb_language mb_output_handler mb_parse_str mb_preferred_mime_name mb_regex_encoding mb_regex_set_options mb_send_mail mb_split mb_strcut mb_strimwidth mb_stripos mb_stristr mb_strlen mb_strpos mb_strrchr mb_strrichr mb_strripos mb_strrpos mb_strstr mb_strtolower mb_strtoupper mb_strwidth mb_substitute_character mb_substr_count mb_substr |