How to reverse a Unicode string

后端 未结 6 1423
你的背包
你的背包 2020-12-06 17:04

It was hinted in a comment to an answer to this question that PHP can not reverse Unicode strings.

As for Unicode, it works in PHP because most app

6条回答
  •  醉话见心
    2020-12-06 17:39

    Another method:

    function mb_strrev($str, $enc = null) {
        if(is_null($enc)) $enc = mb_internal_encoding();
        $str = mb_convert_encoding($str, 'UTF-16BE', $enc);
        return mb_convert_encoding(strrev($str), $enc, 'UTF-16LE');
    }
    

提交回复
热议问题