来自脚本的混合 ascii 和 unicode 输出 - 如何获取命令以全部输出为 ascii?
Mixed ascii and unicode output from script - how to get command to output all as ascii?
我有一个 运行 来自服务的脚本,该服务是使用 C++ 构建的,而不是使用 unicode 构建的。这个程序 运行 是下面的脚本,奇怪的是,wmic qfe 列表行的脚本 运行 的输出似乎输出为 unicode。下面的示例输出。
这是脚本:
@echo off
echo This text is output as standard - no spacing between characters >>C:\log.txt
REM this one is output with 1 space between characters
wmic qfe list >>C:\log.txt
echo This text is also output as standard - no spacing >>C:\log.txt
示例输出
This text is output as standard - no spacing between characters
C a p t i o n C S N a m e D e s c r i p t i o n F i x C o m m e n t s H o t F i x I D I n s t a l l D a t e I n s t a l l e d B y I n s t a l l e d O n N a m e S e r v i c e P a c k I n E f f e c t S t a t u s
h t t p : / / s u p p o r t . m i c r o s o f t . c o m / ? k b i d = 4 0 1 2 2 1 2 M F M - 7 4 2 - 0 - 7 1 S e c u r i t y U p d a t e K B 4 0 1 2 2 1 2 N T A U T H O R I T Y \ S Y S T E M 5 / 1 8 / 2 0 1 7
This text is also output as standard - no spacing
其实我只是用十六进制编辑器查看了文件,字母之间的字符是空字符。所以大概 wmic qfe 列表必须输出 unicode。
那么我如何将其全部输出为 ascii 或全部输出为 unicode。最好以 ascii 格式输出所有内容。
wmic qfe list | find /v "" >> c:\log.txt
wmic qfe list | findstr "^" >> c:\log.txt
将 wmic
命令的输出通过管道传递给 find
或 findstr
命令(如果您对命令没有问题,也可以使用 sort
,或者 more
如果您的输出少于 65535 行),然后再将输出重定向到文件。
我有一个 运行 来自服务的脚本,该服务是使用 C++ 构建的,而不是使用 unicode 构建的。这个程序 运行 是下面的脚本,奇怪的是,wmic qfe 列表行的脚本 运行 的输出似乎输出为 unicode。下面的示例输出。
这是脚本:
@echo off
echo This text is output as standard - no spacing between characters >>C:\log.txt
REM this one is output with 1 space between characters
wmic qfe list >>C:\log.txt
echo This text is also output as standard - no spacing >>C:\log.txt
示例输出
This text is output as standard - no spacing between characters
C a p t i o n C S N a m e D e s c r i p t i o n F i x C o m m e n t s H o t F i x I D I n s t a l l D a t e I n s t a l l e d B y I n s t a l l e d O n N a m e S e r v i c e P a c k I n E f f e c t S t a t u s
h t t p : / / s u p p o r t . m i c r o s o f t . c o m / ? k b i d = 4 0 1 2 2 1 2 M F M - 7 4 2 - 0 - 7 1 S e c u r i t y U p d a t e K B 4 0 1 2 2 1 2 N T A U T H O R I T Y \ S Y S T E M 5 / 1 8 / 2 0 1 7
This text is also output as standard - no spacing
其实我只是用十六进制编辑器查看了文件,字母之间的字符是空字符。所以大概 wmic qfe 列表必须输出 unicode。
那么我如何将其全部输出为 ascii 或全部输出为 unicode。最好以 ascii 格式输出所有内容。
wmic qfe list | find /v "" >> c:\log.txt
wmic qfe list | findstr "^" >> c:\log.txt
将 wmic
命令的输出通过管道传递给 find
或 findstr
命令(如果您对命令没有问题,也可以使用 sort
,或者 more
如果您的输出少于 65535 行),然后再将输出重定向到文件。