Reputation: 21
I am having an issue with setting a variable from a text file in a batch script.
There is only one line in the text file and it is testabc
.
The script is
set /p p_password=<c:\temp\passport.txt
echo %p_password%
The echo statement should have testabc
, but it is actually having the below ■t
.
I even tried it with a for
loop
for /f "delims=" %%a in (c:\temp\passport.txt) do set p_password=%%a
echo %p_password%
I still get the same output; ■t
Any help is much appreciated.
Upvotes: 2
Views: 226
Reputation: 2732
Yes, I can confirm that using different a file encoding format will fix this problem.
Using the input text file mentioned in your question, and saving the text file using UltraEdit
, the results are listed below for the different encoding formats:
testabc
testabc
■t
testabc
t
■
testabc
As mentioned earlier by the commentor, it seems your text file was saved with a Byte order mark.
Upvotes: 1