为什么 mb_convert_encoding 返回 false?
Why is mb_convert_encoding returning false?
这是我的代码:
static function CreateHash($password) {
$upass = mb_convert_encoding($password,'UCS-2LE','auto');
// note I have tried calling the following function to get the
// encoding type of $password and it returns ASCII
// $encoding = mb_detect_encoding($password);
}
如果我用 $password = "abc123!" 调用上面的函数,mb_convert_encoding
returns false
.
"auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS"
但就我而言,它无法正常工作。如果我尝试使用以下代码而不是 'auto'
,我会得到预期的结果:
$upass = mb_convert_encoding($password, 'UCS-2LE', "ASCII,JIS,UTF-8,EUC-JP,SJIS");
这是我的代码:
static function CreateHash($password) {
$upass = mb_convert_encoding($password,'UCS-2LE','auto');
// note I have tried calling the following function to get the
// encoding type of $password and it returns ASCII
// $encoding = mb_detect_encoding($password);
}
如果我用 $password = "abc123!" 调用上面的函数,mb_convert_encoding
returns false
.
"auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS"
但就我而言,它无法正常工作。如果我尝试使用以下代码而不是 'auto'
,我会得到预期的结果:
$upass = mb_convert_encoding($password, 'UCS-2LE', "ASCII,JIS,UTF-8,EUC-JP,SJIS");