Variables 批处理脚本集/p输入特殊西班牙语字符
根据设置变量的方式,我会得到不同的结果 案例1Variables 批处理脚本集/p输入特殊西班牙语字符,variables,batch-file,set,Variables,Batch File,Set,根据设置变量的方式,我会得到不同的结果 案例1 @echo off set TITLE=Cañete setlocal EnableDelayedExpansion set "line=<docTitle><text>%TITLE%</text></docTitle>" ( echo !line! ) > test1.txt @echo关闭 设置标题=Cañete setlocal EnableDelayedExpansion 设置“行=%
@echo off
set TITLE=Cañete
setlocal EnableDelayedExpansion
set "line=<docTitle><text>%TITLE%</text></docTitle>"
( echo !line! ) > test1.txt
@echo关闭
设置标题=Cañete
setlocal EnableDelayedExpansion
设置“行=%TITLE%”
(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
set/P TITLE=(我在这里介绍了相同的单词Cañete)
setlocal EnableDelayedExpansion
设置“行=%TITLE%”
(echo!line!)>test2.txt
我在test1.txt中获得了正确的文本:
<docTitle><text>Cañete</text></docTitle>
Cañete
在test2.txt中,我获得了错误的txt:
<docTitle><text>ca¤ete</text></docTitle>
ca·ete
我的问题:在案例2中,我如何获得正确的答案
<docTitle><text>Cañete</text></docTitle>
Cañete
非常感谢。将CHCP命令应用于第二个代码:
SET /P TITLE= ( I introduce here the same word Cañete )
SETLOCAL ENABLEDELAYEDEXPANSION
CHCP 1252 > NUL
SET "line=<docTitle><text>%TITLE%</text></docTitle>"
(
ECHO !line!
) > test2.txt
CHCP 850 > NUL
SET/P TITLE=(我在这里介绍了相同的单词Cañete)
SETLOCAL ENABLEDELAYEDEXPANSION
CHCP 1252>NUL
设置“行=%TITLE%”
(
回声!线路!
)>test2.txt
CHCP 850>NUL
我希望我已经提供了帮助。将CHCP命令应用于第二个代码:
SET /P TITLE= ( I introduce here the same word Cañete )
SETLOCAL ENABLEDELAYEDEXPANSION
CHCP 1252 > NUL
SET "line=<docTitle><text>%TITLE%</text></docTitle>"
(
ECHO !line!
) > test2.txt
CHCP 850 > NUL
SET/P TITLE=(我在这里介绍了相同的单词Cañete)
SETLOCAL ENABLEDELAYEDEXPANSION
CHCP 1252>NUL
设置“行=%TITLE%”
(
回声!线路!
)>test2.txt
CHCP 850>NUL
我希望我帮了忙