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.