echo “string” > file in Windows PowerShell appends non-printable character to the file

后端 未结 3 584
逝去的感伤
逝去的感伤 2020-12-18 06:14

In Windows PowerShell:

echo \"string\" > file.txt

In Cygwin:

$ cat file.txt
:::s t r i         


        
3条回答
  •  清酒与你
    2020-12-18 06:49

    PowerShell creates Unicode UTF-16 files with a Byte Order Mark (BOM).

    Dos2unix 6.0 and higher can read UTF-16 files and convert them to UTF-8 (the default Cygwin encoding) and remove the BOM. Versions prior to 6.0 will see UTF-16 files as binary and skip them, as in your example.

提交回复
热议问题