"FINDSTR:" Error using special characters in the call function (batch)

I make a game and I want to colorize the dialogues that different characters speak. Everything works well, but only if I do not use '?' in the call function used to color the text (appears as a FINDSTR error). However, I can use the exclamation point without a problem. Any ideas on how to fix this?

Just in case, I included code that colors the text.

EDIT: this part is at the very top of the batch file.

 for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
 set "DEL=%%a"
)

This part goes to the bottom of the batch file.

:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i  

This is mistake:

The filename, directory name, or volume label syntax is incorrect.
FINDSTR: Cannot open  'When did it get so dark outside?' It was morning a few minutes ago...
+4
source share
2 answers

, . , ?, *, :, \, /, ", <, > |.

:

@echo off
setlocal EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)

rem Prepare a file "X" with only one dot
<nul > X set /p ".=."

:

:colorEcho
set "param=^%~2" !
set "param=!param:"=\"!"
findstr /p /A:%1 "." "!param!\..\X" nul
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%"
exit /b

:

call :colorEcho [color] "Text"

. call :colorEcho C "Red"

/ . a \..\ , , , .

: !. .

+1

? ( *, ). .

> "%~2", , .

findstr, , . , , .

findstr , , , . , : ?, *, :, \, /, ", <, >, |.

, i del "%~2" > nul 2>&1i .

0

Source: https://habr.com/ru/post/1649221/


All Articles