Why does mb_convert_case in PHP 5.4 break my line when in 5.2 it isn’t?

I have the following code:

header('Content-type: text/html; charset=utf-8');
$str = 'áá áá';
echo $str."\n";
echo mb_convert_case($str, MB_CASE_TITLE)."\n";
echo bin2hex($str)."\n";
echo bin2hex(mb_convert_case($str, MB_CASE_TITLE))."\n";

Using PHP 5.2.2, I get the following output:

áá áá
áá áá
c3a1c3a120c3a1c3a1
c3a1c3a120c3a1c3a1

Using PHP 5.4.3, I get the following:

áá áá
á  á 
c3a1c3a120c3a1c3a1
c3a1e3a120c3a1e3a1

My expected result in both cases would be:

áá áá
Áá Áá
c3a1c3a120c3a1c3a1
c381c3a120c381c3a1

I have two questions:

  • Why not convert á to Á?
  • Why is PHP 5.4 breaking my lines?
+5
source share
1 answer

Go $encodingto each function call mb_or set:

mb_internal_encoding("UTF-8");

to make sure PHP knows what encoding you are working with. Otherwise, encoding comes from php.inior by default, ISO-8859-1, if it is not included in it.

, 5.4 ISO-8859-1 UTF-8, . 5.2, , , - 5.2, - , internal_encoding ini, ​​ - ?

+6

All Articles