There is a php handler that executes commands like in an exec loop

exec(icacls "\\\\10.0.7.41\\project\\1111_Проект\\01_Подраздел\\19.09.2018_альбом" /inheritance:e /T, $systemMessage);

The utf8 script file encoding without BOM

In the loop about a hundred folders are moved. The execution results are placed in the systemMessage. Tell me how to work correctly with the encoding in which windows returns $systemMessages , An example of what I get by executing on the command line:

enter image description here

But what I get when I try to display data on the screen in a browser or write to a log file

 foreach ($systemMessages as $message){ echo $message; file_put_contents($fileName , $message . PHP_EOL, FILE_APPEND); } 

On the screen: enter image description here It seems to be all right, but when you look into the file, there: enter image description here

What to do with the $ message element in the $ userMessages array, what would it correctly write to the file?

 Пробовал iconv("windows-1251","utf-8",$message) 

Does not help.

  • Duck is not 1251 back, apparently - teran
  • @teran and what is coming back?)) - Igor Tyulkin
  • one
    it looks like koi8r, or on the command line usually cp866 is usually the default. You can change the locale to the desired one before calling exec - teran
  • cp866 came up, thanks. - Igor Tyulkin

0