0

Maybe fgets() isn't what's wrong, but it sure seems that way to me. Try this minimal test setup on for size:

test.bat (Unicode):

@echo off
php test.php

test.php (Unicode):

<?php

    $input = fgets(STDIN);
    file_put_contents('output.txt', $input);

I run test.bat, type "åäö", press Enter, and then open output.txt. It doesn't say "åäö" but instead "NULNULNUL".

What is wrong? I've even tried to add "chcp 65001" in the test.bat (before the php test.php line). Same thing if I do that.

  • Does https://stackoverflow.com/questions/8331353/how-to-read-non-ascii-characters-from-cli-standard-input answer your question? – Patrick Fay Jul 08 '19 at 03:59
  • @PatrickFay Sadly not. Using "chcp 437", as that page says, didn't have any impact. :( –  Jul 08 '19 at 04:04

0 Answers0