Enabling Special Characters in Windows 10

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Enabling Special Characters in Windows 10

#1 Post by atfon » 28 Jul 2021 11:40

This one might be a quick no, given the limitations I'm including. :wink: I had a question about the display of special characters in Windows 10. I've seen from JEB, T3RRY and others how to set a variable to initialize Console Virtual Terminal Sequences in Windows 10 with something like this:

Code: Select all

for /F "delims=#" %%e in ('"prompt #$E# & for %%e in (1) do rem"') do set "\e=%%e"
I know I can then toggle between DEC Line Drawing Mode and ASCII Mode with something like this:

Code: Select all

REM DEC Line Drawing Mode
echo %\e%(0
REM ASCII Mode
echo %\e%(B
Are we then just limited to this DEC Special Graphics Character set?

https://vt100.net/docs/vt220-rm/table2-4.html

Are there any other characters which can be used without adjusting either the encoding of the batch file or the code page of the computer system?

Locale name: en-US
Code Pages: OEM 437
ANSI 1252

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enabling Special Characters in Windows 10

#2 Post by ShadowThief » 28 Jul 2021 12:25

That's all there is, but which characters you have access to will vary based on whether you use the command prompt or the Windows Terminal.

The only letters that work with both are f, g, j, k, l, m, n, q, t, u, v, w, x, y, and z.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#3 Post by atfon » 28 Jul 2021 12:39

Thanks, ShadowThief. I'm interested specifically in the Terminal here. I haven't had any issues using [`], [a] as well as the ones you mentioned. It'll be interesting to see where all this goes in the next major update to Windows 10 (Windows 11).

T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Enabling Special Characters in Windows 10

#4 Post by T3RRY » 29 Jul 2021 23:06

atfon wrote:
28 Jul 2021 12:39
Thanks, ShadowThief. I'm interested specifically in the Terminal here. I haven't had any issues using [`], [a] as well as the ones you mentioned. It'll be interesting to see where all this goes in the next major update to Windows 10 (Windows 11).
There are a few undocumented characters. The below is the complete list for command prompt.

Code: Select all

@Echo off & Cls
 For /f %%e in ('Echo Prompt $E^|cmd')Do Set "\E=%%e"

rem output:          ▒ ° ± ┘ ┐ ┌ └ ┼ ─ ├ ┤ ┴ ┬ │ ≤ ≥ · ♦ ≠ π £
 <nul Set /p "=%\E%(0a f g j k l m n q t u v w x y z ~ ` | { }%\E%(B%\E%[2E"
 <nul set /p "=a f g j k l m n q t u v w x y z ~ ` | { }%\E%[E"
Pause
Given the focus is now on windows terminal, I'd consider it extremely unlikely command prompt will recieve any attention from the microsoft development team.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enabling Special Characters in Windows 10

#5 Post by ShadowThief » 30 Jul 2021 06:59

T3RRY wrote:
29 Jul 2021 23:06
atfon wrote:
28 Jul 2021 12:39
Thanks, ShadowThief. I'm interested specifically in the Terminal here. I haven't had any issues using [`], [a] as well as the ones you mentioned. It'll be interesting to see where all this goes in the next major update to Windows 10 (Windows 11).
There are a few undocumented characters. The below is the complete list for command prompt.

Code: Select all

@Echo off & Cls
 For /f %%e in ('Echo Prompt $E^|cmd')Do Set "\E=%%e"

rem output:          ▒ ° ± ┘ ┐ ┌ └ ┼ ─ ├ ┤ ┴ ┬ │ ≤ ≥ · ♦ ≠ π £
 <nul Set /p "=%\E%(0a f g j k l m n q t u v w x y z ~ ` | { }%\E%(B%\E%[2E"
 <nul set /p "=a f g j k l m n q t u v w x y z ~ ` | { }%\E%[E"
Pause
Given the focus is now on windows terminal, I'd consider it extremely unlikely command prompt will recieve any attention from the microsoft development team.
If you're like me and wondered why some of the characters weren't appearing, make sure the font you're using supports them all. I had to switch from Cascadia Mono to Consolas to get the ▒ to appear.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#6 Post by atfon » 30 Jul 2021 08:09

If you're like me and wondered why some of the characters weren't appearing, make sure the font you're using supports them all. I had to switch from Cascadia Mono to Consolas to get the ▒ to appear.
That's a good point. I was already set to Consolas and had no issues. I don't know if this is possible through batch commands, but it would be nice to be able to toggle the terminal font based on the characters you need.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Enabling Special Characters in Windows 10

#7 Post by ShadowThief » 30 Jul 2021 08:19

atfon wrote:
30 Jul 2021 08:09
If you're like me and wondered why some of the characters weren't appearing, make sure the font you're using supports them all. I had to switch from Cascadia Mono to Consolas to get the ▒ to appear.
That's a good point. I was already set to Consolas and had no issues. I don't know if this is possible through batch commands, but it would be nice to be able to toggle the terminal font based on the characters you need.
In terms of setting fonts, the most consistent way I've found to do it is to create a shortcut to the script and set the font in the shortcut.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#8 Post by atfon » 30 Jul 2021 08:49

In terms of setting fonts, the most consistent way I've found to do it is to create a shortcut to the script and set the font in the shortcut.
True, but it would be handy to be able to swap on the fly as the script is running.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Enabling Special Characters in Windows 10

#9 Post by aGerman » 31 Jul 2021 17:25

it would be handy to be able to swap on the fly as the script is running
This might help: viewtopic.php?f=3&t=10156

Steffen

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#10 Post by atfon » 02 Aug 2021 07:06

Hi Steffen,

That looks really interesting. I will work with the tool you created. Thanks for posting that. I know a number of us have been looking for a solution for doing this for a long time. On a lighter note, did you ever consider DasTips for your handle? Would DosItHelp be jealous of the pun? :lol: :wink:

Thanks again for all your work!

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Enabling Special Characters in Windows 10

#11 Post by aGerman » 02 Aug 2021 11:13

I'm afraid you need to enlighten me on your pun. It might be obvious to a native speaker, but unfortunately not to me :lol:
FWIW I personally find DosTips confusing enough. Certainly doesn't help to separate DOS (operating system) from Windows Batch (scripting language). This forum is way more about the latter :wink:

Steffen

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#12 Post by atfon » 02 Aug 2021 11:19

I was combining the German word "Das" with the English word "Tips" in that the letters are very similar to the domain name of this site. Not that funny, I know. :)
I agree with you about this forum being far more about command line and batch scripting than the old Disk Operating System.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Enabling Special Characters in Windows 10

#13 Post by aGerman » 02 Aug 2021 11:35

It didn't even occur to me that this was a German word :oops: ("Das" is a singular article while Tips is plural which is the reason why I didn't see the relation.)
Besides of that, the founder of DosTips has German roots. I don't think he would be jealous :lol:

Steffen

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#14 Post by atfon » 02 Aug 2021 13:26

...which is the reason why I didn't see the relation.
Which is also why it was intended to be a rather silly "pun." :)
...the founder of DosTips has German roots.
Cool. I didn't know that. Nice to learn a little something about the history of this forum.

atfon
Posts: 178
Joined: 06 Oct 2017 07:33

Re: Enabling Special Characters in Windows 10

#15 Post by atfon » 17 Sep 2021 07:42

I found another way (native to Windows Vista and above) to use extended ASCII from this forum post: viewtopic.php?t=3857
So, I can use code like this to capture the character and display it:

Code: Select all

for /f "delims= " %%g in ('forfiles /p "." /m "%~nx0" /c "cmd /c echo(0xcb"') do set "CB=%%g"
echo %CB%

Post Reply