CMD 设置只读取文本文件中的第一个字母

CMD Set only reading first letter in text file

使用下面的命令Set /p out=<out.txt我没有得到
文件中的文本,返回的只是一个符号和文件中的第一个字母。

我试过使用 Set out=more out.txt 但最终只是将
命令 "more out.txt" 放入脚本而不是文本文件中的内容。
https://i.stack.imgur.com/yU9A1.jpg

貌似out.txt是用UTF-16 encoding with BOM. Unlike type command, the < redirection operator保存的 不懂这个。下面的 cmd 命令应该可以解决问题:

set out=&for /f "delims=" %G in ('type out.txt') do @if not defined out set out=%G

要在批处理脚本(.bat.cmd 扩展名)中使用 FOR 命令,请改为指定 %%G %G 如下:

@ECHO OFF
set "out="
for /f "delims=" %%G in ('type out.txt') do if not defined out set out=%%G