@@ -267,8 +267,7 @@ public static function escapeshellcmd($cmd)
267267 /**
268268 * Prepares token content for output to screen.
269269 *
270- * Replaces invisible characters so they are visible. On non-Windows
271- * operating systems it will also colour the invisible characters.
270+ * Replaces invisible characters so they are visible, and colour them.
272271 *
273272 * @param string $content The content to prepare.
274273 * @param string[] $exclude A list of characters to leave invisible.
@@ -278,35 +277,24 @@ public static function escapeshellcmd($cmd)
278277 */
279278 public static function prepareForOutput ($ content , $ exclude =[])
280279 {
281- if (stripos (PHP_OS , 'WIN ' ) === 0 ) {
282- if (in_array ("\r" , $ exclude , true ) === false ) {
283- $ content = str_replace ("\r" , '\r ' , $ content );
284- }
285-
286- if (in_array ("\n" , $ exclude , true ) === false ) {
287- $ content = str_replace ("\n" , '\n ' , $ content );
288- }
289-
290- if (in_array ("\t" , $ exclude , true ) === false ) {
291- $ content = str_replace ("\t" , '\t ' , $ content );
292- }
293- } else {
294- if (in_array ("\r" , $ exclude , true ) === false ) {
295- $ content = str_replace ("\r" , "\033[30;1m \\r \033[0m " , $ content );
296- }
280+ if (in_array ("\r" , $ exclude , true ) === false ) {
281+ $ content = str_replace ("\r" , "\033[30;1m \\r \033[0m " , $ content );
282+ }
297283
298- if (in_array ("\n" , $ exclude , true ) === false ) {
299- $ content = str_replace ("\n" , "\033[30;1m \\n \033[0m " , $ content );
300- }
284+ if (in_array ("\n" , $ exclude , true ) === false ) {
285+ $ content = str_replace ("\n" , "\033[30;1m \\n \033[0m " , $ content );
286+ }
301287
302- if (in_array ("\t" , $ exclude , true ) === false ) {
303- $ content = str_replace ("\t" , "\033[30;1m \\t \033[0m " , $ content );
304- }
288+ if (in_array ("\t" , $ exclude , true ) === false ) {
289+ $ content = str_replace ("\t" , "\033[30;1m \\t \033[0m " , $ content );
290+ }
305291
292+ if (stripos (PHP_OS , 'WIN ' ) !== 0 ) {
293+ // Printing Unicode characters like '·' to Windows console only works since PHP 7.1.
306294 if (in_array (' ' , $ exclude , true ) === false ) {
307295 $ content = str_replace (' ' , "\033[30;1m· \033[0m " , $ content );
308296 }
309- }//end if
297+ }
310298
311299 return $ content ;
312300
0 commit comments