【发布时间】:2012-05-27 10:48:43
【问题描述】:
根据我设置变量的方式,我得到不同的结果
案例一
@echo off
set TITLE=Cañete
setlocal EnableDelayedExpansion
set "line=<docTitle><text>%TITLE%</text></docTitle>"
( echo !line! ) > test1.txt
案例 2
set /P TITLE= ( I introduce here the same word Cañete )
setlocal EnableDelayedExpansion
set "line=<docTitle><text>%TITLE%</text></docTitle>"
( echo !line! ) > test2.txt
我在 test1.txt 中获得了正确的文本:
<docTitle><text>Cañete</text></docTitle>
在test2.txt中,我得到了错误的txt:
<docTitle><text>ca¤ete</text></docTitle>
我的问题:我如何才能在案例 2 中获得正确的
<docTitle><text>Cañete</text></docTitle>
非常感谢。
【问题讨论】:
标签: variables batch-file set