Problems with mb_convert_encoding

I have some problems with PHP mb_detect_encoding function. I can not convert it to ISO-8859-1. Any help?

The code:

$str = "åäö";
$encoding = mb_detect_encoding($str);
echo $encoding;

$encoding = mb_detect_encoding(mb_convert_encoding($str, "ISO-8859-1"));
echo $encoding;

Conclusion:

Utf-8

Utf-8

Updated solution:

I updated mb_detect_order to an array ('UTF-8', 'ISO-8859-1') and it worked.

+5
source share
2 answers

. , mb_convert_encoding , UTF-8. , ISO-8859-1 ( -). , , mb_detect_encoding, bin2hex . , .

, ( ) . :

mb_convert_encoding($str, 'ISO-8859-1','utf-8');

, , .

+6

mb_detect_order ('UTF-8', 'ISO-8859-1'),

-2
source

All Articles