You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
499 B
26 lines
499 B
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace longbingcore\tools;
|
|
|
|
|
|
class LongbingStr
|
|
{
|
|
|
|
/**
|
|
* @param $str
|
|
* @功能说明:转utf 8
|
|
* @author chenniang
|
|
* @DataTime: 2020-01-03 19:23
|
|
*/
|
|
|
|
static public function strToUtf8($str){
|
|
$encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));
|
|
if($encode == 'UTF-8'){
|
|
return $str;
|
|
}else{
|
|
return mb_convert_encoding($str, 'UTF-8', $encode);
|
|
}
|
|
}
|
|
} |