Can I use echo to generate an UTF-8 text file? For example if I want to generate a file that contains the character ę
:
echo "abcd ę" > out.txt
(the batch file is encoded with UTF-8)
the result is an ANSI encoded file and the ę
character is transformed into ê
. How can I convince echo
to generate an UTF-8 file?
If it's not possible, then can I change the encoding of the text file after creating it? Is there any tool in the gnuwin32 package that can help me to change the encoding?
thanks
batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
Represents a replaceable parameter. Use a single percent sign ( % ) to carry out the for command at the command prompt. Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> )
This batch command displays messages, or turns command echoing on or off.
When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.
Use chcp
command to change active code page to 65001 for utf-8.
chcp 65001
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With