Answer the question
In order to leave comments, you need to log in
How to create a /not/empty text file with utf-8 encoding via cmd (without connecting external utilities)?
Tried like this:
chcp 1251
cmd /d /u /c type d:\1251.txt > .tmp
chcp 65001
type .tmp > d:\utf8_out.txt
del .tmp
Answer the question
In order to leave comments, you need to log in
An empty text file cannot have an encoding in principle.
txt does not store encoding information at all. Notepad picks it up by analyzing the file usually.
Unicode encodings can write a BOM marker at the beginning of the file, but it will no longer be an empty file.
How to create an empty text file with utf-8 encoding via cmd (without connecting external utilities)?
Something like this, replace d:\newfile.txt with the path to the file:
@echo -----BEGIN CERTIFICATE----- > %TEMP%\tmp64.txt
@echo 77u/YXNk >>%TEMP%\tmp64.txt
@echo -----END CERTIFICATE----- >>%TEMP%\tmp64.txt
certutil -decode %TEMP%\tmp64.txt %TEMP%\tmp.txt
copy %TEMP%\tmp.txt d:\newfile.txt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question