php 5.4 - php 5.4 charset for Exception -


My code does not work properly in PHP 5.4. I use Cyrillic charset briefly:

< Pre class = "lang-php prettyprint-override"> throw a new exception ('Сообщение');

The output will be:

Fatal error: in test.php ...

However the result will be: < / P>

Fatal Error: Exception exception with the message "Exceptions" ...

If I do not use Cyrillic characters, the result is OK . Also, if I run this code in 5.3, then I will get the proper result. To wit. If I use Cyrillic, the result message is an empty string.

Try converting character messages to UTF-8 in non-UTF-8 exceptions:

  Throw new exception (utf8_encode ('Сообщение'));  

If that does not work, try the following:

  $ message = 'Сообщение'; $ Message = mb_convert_encoding ($ message, 'windows-1251', 'UTF-8'); Throw a new exception ($ message);  - 

- Edit -

The real problem is not that the exception message is stored, but rather - the exception is In correctly displayed PHP 5.3, xdebug is not turned on by default and in PHP 5.4, it is. Xdebug is set to display everything in UTF-8 and your message is probably encoded in some other charset, thus this message is not being presented properly

If you have page If you scroll down to the bottom, you will get a single comment referring to this problem.

PHP itself tracked this issue

Also related to this issue

You can get away with setting xdebug encoding in a non-utf-8 charset Are there. Please


Comments