0

I was recently overwhelmed with quick responses for a question I had the other day! hopefully this will be a quick one for those in the know, I've searched and played for hours and just not getting it.

I have found code to modify color per character in batch CMD although cant make it work for ASCII characters.

This shows hows output window with errors:
screenshot

Here's the code I've tried to modify to suit, it explains exactly whats happening and what im attempting:

@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"
)

call :colorEcho 0a "This works!!"
echo.
call :colorEcho 0C "But ASCII characters don't"
echo.
echo expect this in set color 
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º                             º
echo º                             º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.    
echo but get this instead?
echo.
call :colorEcho 0a "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
echo.
call :colorEcho 0a "º                             º"
echo.
call :colorEcho 0a "º                             º"
echo.
call :colorEcho 0a "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
pause
exit

:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
aschipfl
  • 28,946
  • 10
  • 45
  • 77
ryan
  • 31
  • 1
  • 9
  • What codepage you are using? Characters on screenshoot differ from character in batch file. You can use [ansicon](https://github.com/adoxa/ansicon) to coloring charaters in windows shell script. – user2956477 Dec 18 '16 at 11:54
  • Sorry mate, I'm very new to this and don't understand what you're asking.. all I know is when I save the batch file with default ANSII encoding the output become the characters shown in screenshot. Hopefully this is what your asking? Also if at all possible I'm hoping to do this without external program. Thanks for your help – ryan Dec 18 '16 at 12:11
  • 3
    Possible duplicate of [How to have multiple colors in a Windows batch file?](http://stackoverflow.com/questions/4339649/how-to-have-multiple-colors-in-a-windows-batch-file) – SomethingDark Dec 18 '16 at 13:28
  • 2
    You mean you are having problems with extended ASCII characters. – Squashman Dec 18 '16 at 18:38

1 Answers1

1

Seems my solution was more simple than i ever expected, once i stopped and thought about it.

so because i want all extended ascii characters to be the same color its simple.

change the whole page to match what color i want menu border (extended ascii characters) using simple color function

and then color all the text separately using the call :colorEcho from my original script.

thanks

ryan
  • 31
  • 1
  • 9
  • +1 That is a simple and clever solution - I like it! There is a solution for multi-color extended ASCII at the bottom of [this answer - Update 2012-12-14 section](http://stackoverflow.com/a/10407642/1012053), but it slows things down considerably. – dbenham Dec 21 '16 at 13:17