We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. When trying to script a few build-related things we've stumbled upon a problem - we can't pass the š letter to the command-line tools. The command prompt or what not else messes it up, and the tf.exe utility can't find the specified project.
I've tried different formats for the .bat file (ANSI, UTF-8 with and without BOM) as well as scripting it in JavaScript (which is Unicode inherently) - but no luck. How do I execute a program and pass it a Unicode command line?
Press and hold the Left Ctrl and Shift keys and hit the U key. You should see the underscored u under the cursor. Type then the Unicode code of the desired character and press Enter. Voila!
To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.
In Windows, you can type any character you want by holding down the ALT key, typing a sequence of numbers, then releasing the ALT key.
Windows Terminal includes multiple tabs, panes, customizable shortcuts, support for Unicode and UTF-8 characters, and custom themes and styles. The terminal can support PowerShell, cmd, WSL, and other command-line tools.
Try:
chcp 65001
which will change the code page to UTF-8. Also, you need to use Lucida console fonts.
My background: I use Unicode input/output in a console for years (and do it a lot daily. Moreover, I develop support tools for exactly this task). There are very few problems, as far as you understand the following facts/limitations:
CMD
and “console” are unrelated factors. CMD.exe
is a just one of programs which are ready to “work inside” a console (“console applications”).CMD
has perfect support for Unicode; you can enter/output all Unicode chars when any codepage is active. chcp 65001
is very dangerous. Unless a program was specially designed to work around defects in the Windows’ API (or uses a C runtime library which has these workarounds), it would not work reliably. Win8 fixes ½ of these problems with cp65001
, but the rest is still applicable to Win10.cp1252
. As I already said: To input/output Unicode in a console, one does not need to set the codepage.File-I/O
API, but Console-I/O
API. (For an example, see how Python does it.)U+10000
). Only simple text rendering is supported (so European — and some East Asian — languages should work fine — as far as one uses precomposed forms). [There is a minor fine print here for East Asian and for characters U+0000, U+0001, U+30FB.]The defaults on Window are not very helpful. For best experience, one should tune up 3 pieces of configuration:
One more gotcha with “Pasting” into a console application (very technical):
KeyUp
of Alt
; all the other ways to deliver a character happen on KeyDown
; so many applications are not ready to see a character on KeyUp
. (Only applicable to applications using Console-I/O
API.)Ctrl-Alt-AltGr-Kana-Shift-Gray*
) then it is delivered on an emulated keypress. This is what any application expects — so pasting anything which contains only such characters is fine.Conclusion: unless your keyboard layout supports input of A LOT of characters without prefix keys, some buggy applications may skip characters when you Paste
via Console’s UI: Alt-Space E P
. (This is why I recommend using my keyboard layouts!)
One should also keep in mind that the “alternative, ‘more capable’ consoles” for Windows are not consoles at all. They do not support Console-I/O
APIs, so the programs which rely on these APIs to work would not function. (The programs which use only “File-I/O APIs to the console filehandles” would work fine, though.)
One example of such non-console is a part of MicroSoft’s Powershell
. I do not use it; to experiment, press and release WinKey
, then type powershell
.
(On the other hand, there are programs such as ConEmu
or ANSICON
which try to do more: they “attempt” to intercept Console-I/O
APIs to make “true console applications” work too. This definitely works for toy example programs; in real life, this may or may not solve your particular problems. Experiment.)
set font, keyboard layout (and optionally, allow HEX input).
use only programs which go through Console-I/O
APIs, and accept Unicode command-line arguments. For example, any cygwin
-compiled program should be fine. As I already said, CMD
is fine too.
UPD: Initially, for a bug in cp65001
, I was mixing up Kernel and CRTL layers (UPD²: and Windows user-mode API!). Also: Win8 fixes one half of this bug; I clarified the section about “better console” application, and added a reference to how Python does it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With