I need to convert a text file to UTF-8 format via Windows command prompt. This needs to be done on another machine and I do not have rights to install software on that machine. I need something like:
c:\notepad source-file target-file --encoding optionIs there a Windows command prompt utility which can do it?
4 Answers
I need to convert a text file to utf-8 format via windows command prompt
You can easily do this with PowerShell:
Get-Content .\test.txt | Set-Content -Encoding utf8 test-utf8.txtFurther Reading
7Use iconv from GNUWin32 pack. It is much faster, especially if your files are about or more than 1 Gb.
"C:\Program Files (x86)\GnuWin32\bin\iconv.exe" -f cp1251 -t utf-8 source.txt > result.txt 3 Here is for each convert *.text file to *.sql file:
foreach ($file in get-ChildItem *.txt) { Echo $file.name Get-Content $file | Set-Content -Encoding utf8 ("$file.name" +".sql") } 1 You can do this from the command prompt as follows:
powershell -command "Get-Content .\test.txt" > test-utf8.txtIt turns out that piping the output to a file from the command prompt saves as utf-8.