Current Location: Home> Function Categories> mb_convert_kana

mb_convert_kana

Change "Kasaname" to another ("zen-kaku", "han-kaku", etc.)
Name:mb_convert_kana
Category:Multi-byte string
Programming Language:php
One-line Description:Convert half-width characters in a string to full-width characters, or convert full-width characters to half-width characters

Function name: mb_convert_kana()

Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7

Usage: mb_convert_kana(string $str [, string $option = "KV" [, string $encoding = mb_internal_encoding() ]]): string

Description: The mb_convert_kana() function is used to convert half-width characters in a string into full-width characters, or to convert full-width characters into half-width characters.

parameter:

  • $str: The string to be converted.
  • $option: Optional parameter, specifying the conversion method. The default is "KV", which means converting half-width Katakana to full-width Katakana and full-width British digits to half-width. Other optional values ​​are:
    • "K": Convert half-width Katakana to full-width Katakana.
    • "V": Convert full-width Katakana to half-width Katakana.
    • "a": Convert full-width English numbers into half-width.
    • "A": Convert half-width English numbers to full-width.
    • "n": No conversion is made.
  • $encoding: Optional parameter, specify character encoding. The default value is mb_internal_encoding(), which is the current internal character encoding.

Return value: Returns the converted string.

Example:

 $str = "hello,world!"; $result = mb_convert_kana($str, "a"); echo $result; // 输出:hello, world!
 $str = "こんにちは、世界!"; $result = mb_convert_kana($str, "K"); echo $result; // 输出:?????、世界!
 $str = "????"; $result = mb_convert_kana($str, "K"); echo $result; // 输出:カタカナ

Notes:

  • The mb_convert_kana() function is a multibyte character encoding function that requires setting the correct internal character encoding through mb_internal_encoding() before use.
  • Please make sure that the encoding of the string is consistent with the specified character encoding to avoid garbled code problems.
  • This function is only suitable for handling Japanese characters.
Similar Functions
Popular Articles