I have a little c# console program that outputs some text using Console.WriteLine. I then pipe this output into a textfile like:

c:myprogram > textfile.txt

However, the file is always an ansi text file, even when I start cmd with the /u switch. cmd /? says about the /u switch:

/U Causes the output of internal commands to a pipe or file to be Unicode

And it indeed makes a difference, when I do an

c:echo "foo" > text.txt

the text.txt is unicode (without BOM)

I wonder why piping the output of my console program into a new file does not create an unicode file likewise and how i could change that?

I just use Windows Power Shell (which produces a unicode file with correct BOM), but I'd still like to know how to do it with cmd.

Thanks!

Edit
Report