how to transform japanese english character to normal english character?

前端 未结 2 1451
太阳男子
太阳男子 2020-12-20 00:46

I have an japanese english character. This character is not normal english string.

Characters: Game

How to transform this character to norm

相关标签:
2条回答
  • 2020-12-20 01:19

    Subtract 65248 from the ordinal value of each character. In other words:

    $str = "Game some other text by ヴィックサ";
    $str = preg_replace_callback(
        "/[\x{ff01}-\x{ff5e}]/u",
        function($c) {
            // convert UTF-8 sequence to ordinal value
            $code = ((ord($c[0][0])&0xf)<<12)|((ord($c[0][1])&0x3f)<<6)|(ord($c[0][2])&0x3f);
            return chr($code-0xffe0);
        },
        $str);
    

    This will replace all of the "Fullwidth" characters with their normal width equivalents.

    0 讨论(0)
  • 2020-12-20 01:33

    I'm sure there is a much easier answer but couldnt you make a dictonary object with the special charter as the key and the char you want as the value

    then just do a simple find and replace?

    0 讨论(0)
提交回复
热议问题