en-UShe-IL
You are here:   Blog
Register   |  Login

Blog Archive:

Maximize
* Can be used in order to search for older blogs Entries

Search in blogs


Blog Categories:

Maximize
* Can be used in order to search for blogs Entries by Categories

Blog Tags:

Maximize
* Can be used in order to search for blogs by keywords

TNWikiSummit


Awared MVP 


 


Microsoft® Community Contributor 


Microsoft® Community Contributor


 Read first, before you you use the blog! Maximize
פבר22

Written by: ronen ariely
22/02/2014 21:34 RssIcon

Case Study: Console command shell Using Hebrew

Any common operating system include a Text-based command interface, which provides the environment in which the user can move commands, launch applications and run services. by default the windows command shell aloud use to use English, but what if we want to use Hebrew or any other local language? what if we want to develop a console application which use local language?

In this blog I will explain step by step, how to configure the command (CMD) console shell, to use local language [Hebrew for example]. This will also affect Powershell.

Introduction

The command shell is a separate software program that provides direct communication between the user and the operating system. The non-graphical command shell user interface provides the environment in which you run character-based applications and utilities. The command shell executes programs and displays their output on the screen by using individual characters, similar to the MS-DOS command interpreter.

The command interpreter is a file responsible for handling and processing the command done at the MS-DOS or Windows command line interface. For example, the command interpreter for earlier Microsoft operating systems is the file command.com, later versions of Windows use the cmd.exe file.

The Windows command shell uses the command interpreter Cmd.exe, which loads applications and directs the flow of information between applications, to translate user input into a form that the operating system understands.

By default the command interpreter is using the English language, but it can be adjusted to work with local languages as well. In this example I will demonstrate using the command shell with Hebrew.

The solution

There is basically two operations which need to be done:

1. Choosing the right font

2. Choosing the right encoding (code page)

The first step is a one-time-action including editing the operating system registry, and configuration of the command shell interface, while the second step best done using a dynamic command. 

Before we start!!! Those actions are not recommended to do, if you do not have a full understanding of the Operation System Registry Keys! In any case, make sure you backed up the Operation System and the Registry Keys before any change is done!

Details of operations, step by step

1. Open the Operation System Registry Editor GUI    run -> regedit

2. Navigate to the registry key: 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont]

3. Add new registry string value keys (Key/Value pairs) 

add -> New string value

4. Repeat step 3 until you have all those keys/values:

* This fonts are fit for Hebrew. You should make sure that you choose the right fonts for your languages! The fonts mast be true-type font, and not every font will fit our case. 

Key Name    /   Value
0           /   Lucida Console
00          /   Everson Mono
000         /   Consolas
0000        /   Courier New

5. Open the command shell console 

run -> cmd

6. Right click on the command shell console window's title -> select "properties"

7. Move to the "Font" tab

* You can see in the font list the fonts that we added in the registry keys editor (step 1-4). If you don’t see the font which you want to use then probably, this font is not installed, is not a true-type font, or is not fit for the console application.

8. Choose "Courier New"

* I highly recommend to use this time to customize several more configurations: (1) move to the "Options" Tab -> mark the textbox "QuickEdit Mode", This option provides an easy way to copy text from (and paste text into) command shell using the mouse. (2) Move to the "Colors" tab and choose the colors that you like (I prefer white as background an black or the text for example).

9. Click OK

10. Click "Save properties for future windows with same title", and then click OK.

11. Choosing the encoding

On the command shell which we want to see local language (Hebrew in our case) we need to make sure that the console is working with appropriate encoding. This action is needed only if this is not the default encoding (if you can't see Hebrew then your font is probably not fit or you have to do this action). We can change the encoding using this command (862 fit for Hebrew):

chcp 862

The Hebrew codepage command for console ("OEM") is chcp 862 (default-character-set=cp862) and the "ANSI" one is chcp 1255. Make sure you have them installed under Regional and Language Options before you use them.

If the system support the font and the encoding that we choose then you can see your languages now. Here is Hebrew text on our console: 

Have fun :-)

Resources

Command shell overview
* http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true
* http://en.wikipedia.org/wiki/Shell_(computing)

Customize the Command Prompt in Windows 7
* http://technet.microsoft.com/en-us/magazine/ff758104.aspx

Forum's questions

* http://social.msdn.microsoft.com/Forums/sqlserver/he-IL/30dd5b8c-32bc-436a-8fef-3a71cf47e7f8/-?forum=nethe

* http://social.msdn.microsoft.com/Forums/sqlserver/he-IL/f1c4699d-1411-423f-a43e-fba4fc5a9b69/-?forum=nethe

http://powershell.com/cs/forums/t/11793.aspx

http://superuser.com/questions/257333/hebrew-utf8-characters-in-windows-cmd-console/720492