始于此, 终于斯
文章31
标签0
分类13

字符转码

// 使用默认字符编码识别可能导致识别错误
//$encoding = mb_detect_encoding($string, mb_detect_order(), true);
// 默认mb_detect_order() => ASCII,UTF-8

// 手动指定识别顺序
$encoding = mb_detect_encoding($string, 'GB2312,GBK,ASCII,UTF-8,ISO-8859-15', true);
if ($encoding) {
    $string = mb_convert_encoding($string, "UTF-8", $encoding);
} else if (mb_detect_encoding($string, 'GB2312', true)) {
    $string = mb_convert_encoding($string, "UTF-8", 'GB2312');
} else {
    $string = mb_convert_encoding($string, "UTF-8", 'GBK');
}

Composer PHP版本要求过高

"config": {
    "platform-check": false
},
composer update
composer dump-autoload