<?php
header("Content-Type: text/plain; charset=UTF-8"); // output as text file
header("Content-Type: text/html; charset=UTF-8"); // output as HTML
header("Accept-Charset: utf-8");
mb_internal_encoding('UTF-8');
$output_file = 'C:\\junk.txt';
$input = $argv[1];
file_put_contents($output_file, 'я ' . mb_detect_encoding($argv[1]) . ': ' . $argv[1]);
return;
?>
On the command prompt:
php C:\test.php я
The resulting file:
я ASCII: ?
I've tried changing the code page to 65001, that didn't help. How in the world do I pass a unicode character to PHP from the command prompt? It just assumes everything is ASCII. I'm expecting it to print out:
я UTF-8: я