Converting text file to UTF-8 on Windows command prompt
Solution 1:
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.txt
Further Reading
- Convert from most encodings to utf8 with powershell
Solution 2:
Use 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
Solution 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")
}