1

I am making a text to binary encoder with a batch code. In order to do that, I need to know how to store just a space inside a variable. The code below is an example of how it may be.

@echo off
set test=I am
set char2=%test:~1,1%

This code supposedly stores the second character of %test% (which is space) in %char2%. However, when I echo char2 to verify that this worked, I only get "ECHO is ON" and the variable is not treated as having any input. I hope anyone could help. Thank you!

1
  • try echo "%char2%"
    – Hannu
    Jun 23, 2020 at 17:13

1 Answer 1

1

Why not?

set "_spc= "

echo.%_spc%
echo\%_spc%
echo/%_spc%
echo[%_spc%
echo(%_spc%
echo=%_spc%
echo;%_spc%

rem :: or...

set "test=I am"
set "char2=%test:~1,1%"

echo\%char2%
echo/%char2%
echo.%char2%
echo=%char2%
echo[%char2%
echo(%char2%
echo;%char2%

This options can prevent ECHO is ON message...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .