Save text file in UTF-8 encoding using cmd.exe Save text file in UTF-8 encoding using cmd.exe windows windows

Save text file in UTF-8 encoding using cmd.exe


The default encoding for command prompt is Windows-1252. Change the code page (chcp command) to 65001 (UTF-8) first and then run your command.

chcp 65001C:\Windows\system32\ipconfig /all >> output.log

Change it back to default when done.

chcp 1252


As the existing answer says, in a batch file, you can use the chcp command

chcp 65001 > nulsome_command > file

But if you are using the cmd.exe from its command line, e.g. to execute a user-defined command, you can use this syntax:

cmd.exe /c chcp 65001 > nul & cmd.exe /c some_command > file