I want to type and print in windows 10 CMD sinhala unicode characters. but it just display question mark surrounded by a square for each sinhala character i type.
Is there any mechanism to display exact unicode characters in windows console?
Try modifying the registry settings for the cmd console (run regedit). Unfortunately, I am uncertain exactly which value you should enter for the font family, since it is a number.
The screen shot below shows my registry settings for a font of 'Courier New', which somehow translates to 30 (hexidecimal, 48 in base 10) in the registry. Hopefully you can experiment some and determine what number corresponds to a Sinhala font you have installed on your machine.
Additionally, you can select fonts using the cmd window's property dialog, illustrated in the screen shot below. Possibly you already have a font installed that you can use:
You've probably already done 1-3 since you can already type Sinhala, but you need a supporting font. Try the following:
Go to Region & language settings.
Add a language and select, Sinhala.
Click the language, Select Options, and you can select a keyboard type.
For Chinese, I was able to add a language pack, which gave me console fonts that support Chinese. I don't see that option for Sinhala. You may have to manually install a monospace font that support Sinhala. I couldn't find one, but if you do, this answer explains how to install it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
A long time ago I wanted to change the default codepage (CP) of windows console to UTF-8 (to view japanese characters). I can't remember the commands I used, but anyway I eventually managed to be able to view the characters on the cmd.exe. After a short time though, I noticed any programs using the cmd.exe would be in the Japanese codepage 932 by default and OEMCP was set to 932. After noticing this I checked the System Locale and changed it to English (United States). After doing this it was expected that OEMCP would have changed to 437, which it had and which also should have meant the default CP of cmd.exe was now 437. However even after the OEMCP had been changed to 437 the default CP of cmd.exe was still 932.
So how can I change the default CP back to 437? What is causing it to still be CP 932 by default? I have completely removed the Japanese Language from my PC to make sure it wasn't causing the issue, and many people have told me to use an autorun file or change the OEMCP to use CP 437, however OEMCP is already set as 437 and I do not want to use an autorun file for CP 437, I simply want it to be the default as it used to be.
I have also been told that there could be a script that's auto-running each time the cmd.exe is opened, but I have no idea how to track that or how to remove it.
Updates:
The issue is with cmd.exe using CP 932
powershell.exe and netsh.exe are both already using CP 437
The default configuration for console windows is stored in the registry key "HKCU\Console". Most of the properties in this key are configurable in the GUI using the console's Alt+Space [D]efaults dialog.
When a process allocates a new console, some of these defaults are directly overridden by the process STARTUPINFO. This includes the window position and size and the screen buffer size and fill attribute (i.e. text and background colors). The process startup information also includes an initial window title, which, if not set by the parent process, defaults to the fully-qualified path of the application executable. If the application is launched using a shell shortcut (i.e. LNK file), the title will be the path to the shortcut file instead of the executable, and the flag STARTF_TITLEISLINKNAME will be set.
The console uses the initial window title to load additional properties that customize the window. If the STARTF_TITLEISLINKNAME flag is set, it loads these additional properties from the LNK shortcut file that launched the application. Otherwise it looks for the normalized title as a subkey in the registry. To normalize the title, backslashes are replaced with underscore, and the Windows directory is replaced by "%SystemRoot%". For example, if the initial window title is "Spam\Eggs", it looks for settings under "HKCU\Console\Spam_Eggs". These properties are configurable in the GUI using the console's Alt+Space [P]roperties dialog.
One of the properties that can be set is a DWORD value named "CodePage". This is the initial legacy codepage for both input and output. (I say "legacy" because the console has a Unicode API that should always be preferred.) If it's not set, the console defaults to the OEM codepage (e.g. 850 in Western Europe or 437 in the U.S.). A LNK shortcut can also set a custom codepage in its ConsoleFEDataBlock, but it's not possible to modify this using the GUI, or even using the IShellLink COM interface.
For example, if cmd.exe is run directly from the Win+R run dialog instead of using a shortcut, it uses the default window title "C:\Windows\System32\cmd.exe". The console in turn, after loading its defaults from "HKCU\Console", looks for additional configuration in the subkey "HKCU\Console\%SystemRoot%_System32_cmd.exe". A "CodePage" value set there will override the console's default OEM codepage.
Unfortunately, if we want to change the initial codepage for all console applications, we'll be disappointed that setting it in "HKCU\Console" doesn't work. Due to a bug in the console (currently implemented by conhostv2.dll, which is hosted in conhost.exe), if we set a default "CodePage" value in "HKCU\Console", the console only briefly sets this value while loading and then resets itself to OEM.
Some time ago I had to change my system locale from Czech (default) to Japanese because I needed to run some Japanese programs that would otherwise crash.
The problem is, after switching back to Czech, my command prompt would launch with the Shift-JIS encoding whenever I opened it from the Win+R dialog (which is my preferred way of launching cmd). It would also draw characters in a strange bloated font. The problem persists even after uninstalling Japanese from my system altogether.
If I open cmd any other way (Start menu, Right-click Start -> Command Prompt, cmd.exe...), everything works correctly. All settings that I could think of are set to Czech:
System locale
Language for non-Unicode programs
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage (OEMCP value)
Another thing is that Regedit always opens on HKEY_CLASSES_ROOT\MIME\Database\Codepage, though I don't know if that's related to the problem.
I'm running Windows 10, after the free upgrade from 8.1 and 7. Picture shows the different cmd windows.
http://i.imgur.com/jyyhAOA.png
Settings are stored a number of places. Look here for a codepage value and delete it.
HKCU\Console\%SystemRoot%_system32_cmd.exe\
A nearly identical question was asked before. A good explanation of code pages was given in the reply, but it did not answer the question in my mind: What controls the code page used when cmd.exe is started? On my system, it gets changed somehow. In the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage, there is an item OEMCP that is set to 437. This seems to be the CP used by cmd.exe (as shown by chcp) after a fresh reboot, but something changes it later and it becomes 1252 in new cmd.exe windows. If I change it with chcp to 437, that only affects the current cmd.exe. When I exit and restart cmd.exe, chcp shows 1252 in the new window. What controls the default CP used when cmd.exe is started? How does it get changed from the value in the registry? How do I keep it from getting changed and/or change it back to 437 for new command windows?
The default code page in cmd.exe on my Windows syxtem is 437, which is the default OEM code page for most PC hardware sold in the United States (US) and Western Europe from what I've read. You can change this default by adding a string entry named AutoRun under one or both of the keys:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
and
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor
in the Windows registry, as documented on this MS Windows Server 2003 support page. It describes how you can add a REG_SZstring entry named AutoRun under one or both of these keys with a value containing commands you want run automatically when cmd.exe starts up.
For example, to make code page 1252 the default, create a new string value named AutoRun after navigating to one of these keys in the regedit.exe utility program and then set its value to the command chcp 1252 afterwards.
Although the MS article only indicates it applies to Windows Server 2003, the technique also worked on the Win XP system I tested it on, so will probably also work with Vista & Win 7.
If Win+R and running cmd.exe /D fixes it then the problem is in the cmd autorun value...
I have a wide-character file (with Hebrew text) that looks fine in Notepad (saved in "UTF-8 encoding"), reads fine in Notepad++, and when I copy-and-paste into MS Word it looks fine too. But when I open a "DOS box" (Windows console) and go: "type file.txt", it prints gibberish.And yes, I've done all the recommendations for Unicode on Windows console: I opened the console using "cmd /u", I changed the font to Lucida, and I've entered: "chcp 65001".
The problem is identical on a PC running Windows 7, and on another PC running Windows XP SP3.
The Font Courier New supports hebrew and can be added to the command prompt. The default fonts are consolas, lucida, raster, none of them support hebrew. So add Courier New to the command prompt.
It's a registry hack to do that
http://www.howtogeek.com/howto/windows-vista/stupid-geek-tricks-enable-more-fonts-for-the-windows-command-prompt/
http://www.techrepublic.com/blog/windows-and-office/quick-tip-add-fonts-to-the-command-prompt/
This is a good example of how to install fonts, but I should remove a lot of these entries, because most of them didn't get added to cmd because cmd didn't support them.
Lucida and Consolas are defaults.
Raster is a default not listed here maybe 'cos it's a TTF
Of all these I tried to add, only 3 added(are supported by cmd)
Courier New, DejaVu Sans Mono, Droid Sans Mono
DejaVu Sans Mono and Droid Sans Mono are downloadable, supported by cmd, might have some good unicode support/characters, but don't include Hebrew
I have
Consolas <-- default
Courier New <--- added
DejaVu Sans Mono <-- added
Droid Sans Mono <-- added
Lucida Console <-- default
Raster Fonts <-- default
Common hebrew fonts are Miriam and David, but they can't be added to the command prompt.
For the record, Babelmap can list all fonts on your system that support hebrew e.g. in babelmap- click fonts..font coverage, then enter 05D0(that's aleph). I think all these fonts exist on a default windows 7 installation
Aharoni, Arial, Courier New, David, FrankRuehl, Gisha, Levenim MT, Lucida Sans Unicode, Microsoft Sans Serif, Miriam, Miriam Fixed, Narkisim, Rod, Segoe WP, Tahoma, Times New Roman
But most or all of those fonts with hebrew aren't supported in the command prompt, except Courier New. In fact most fonts full stop aren't supported in the command prompt, not even "times new roman"(because "times new roman" is not mono-spaced / fixed width, and that's one of a number of criteria for it to be supported, other criteria seem to be more obscure).
So now you can have Courier New added and selected for use in the command prompt.
And so you can paste unicode characters onto cmd provided the selected font supports it.
To copy/paste, click the Copy button in charmap
Now it's in the clipboard
To paste it into the command prompt, in win7 paste into command prompt isn't ctrl-v. You right click and choose paste. (or if in quickedit mode then just rightclick)
That's the main thing.
Additionally
Often in windows one might use notepad and character map.. but one should be aware of some limitations with them.
Character map shows the first 65536 unicode characters when the font you selected supports it, and character map shows you the UTF-16 code. That's ok, you can still paste from character map into a cmd.exe window, but you should know that commands run in cmd.exe and pipes don't support utf-16. So you can use character map, find a character e.g. aleph 05d0, but it's worth looking up the character on http://www.fileformat.info/info/unicode/char/05d0/index.htm and seeing that while the utf-16 code is 05d0, the utf-8 code is d790. The xxd command and file command is useful for seeing the real contents of a file and determining the file's type.
Notepad is a bit limited when it comes to unicode or any character in the unicode character set whose UTF16 code is > FF. And cmd is a bit limited in regard to some commands like 'type', and in regard to pipes and redirection.
If using cmd.exe you really need pipes to work 'cos pipes are important..
Pipes are limited to the encodings that can be specified by the CHCP Command.
(Note that if CHCP tells you you are on a particular codepage, e.g. 850, it's telling you the input encoding. If you run the command chcp 850 it will change both the input and output encodings. Usually they are the same. It's simpler when they are the same. But if you used some other program to change the encoding of cmd eg the c# compiler has a switch that changes it, then it's best to change it with chcp so you know both encodings are set ).
There is a CHCP 1200 (UTF-16LE) and 1201(UTF-16BE) , but neither are supported, if you try it it will say invalid codepage (tested in win7). CHCP doesn't support UTF-16(it doesn't support UTF16LE or UTF16BE). There is CHCP 65001 (That's UTF-8 without BOM). And there is CHCP 862 (the old fashioned way as in MSDOS days way, of encoding Hebrew, that I mentioned)
The type command supports UTF16LE as does notepad(What notepad calls Unicode, is UTF-16 LE), But pipes and redirection don't support that. The type command also supports any codepage specified/supported by CHCP. So type supports 862 or 65001.
So you could use notepad save it as UTF8 (which is with BOM), then fiddle around to remove the BOM. (That's a bit overkill).. Or you could use notepad, save it as Unicode UTF 16LE.. But then you can't sue pipes.. (that's bad).. Easiest thing to do is use a text editor like notepad2 or notepad++, that supports UTF8 without BOM.
Or if doing everything from cmd you could use 862 or 65001. Though many text editors might not give good support of 862. So you might prefer 65001.
If you want to write any file in notepad and it has a character greater than what in UTF16 is referred to as \uFF, and you want to run commands in cmd.exe on that file, then some commands (e.g. the type command), will have problems if you don't take into account what is supported by what.
Notepad supports UTF-16BE, UTF-16LE and UTF-8 with BOM. That's not good. And no need to fiddle around with xxd and sed or other commands to remove the BOM. If you have any file with a so-called unicode character, a character outside of the regular ascii range. A character > UTF-16's \uFF, as shown by character map as being > \uFF, then use Notepad2 or notepad++
Type supports UTF16LE, and any codepage set by CHCP e.g. 65001 or 862.
Pipes and redirection go by whatever is set by CHCP.
Codepage 862 is old so Codepage 65001 is a good way to go.
xxd and file are useful for seeing how a file is encoded which can be helpful if you have issues. But not absolutely necessary.
So if you want to write a file for use in CMD, and it has some unicode characters, while thee are some commands like xxd and sed that could be used to remove a BOM, and other commands to do so. The easiest way to make such a file in a text editor is to use a text editor like notepad2 or notepad++ which supports UTF8 without BOM.
Getting hebrew displaying might be the most important thing to do first, as described above. And the next thing is being able to save files in a text editor that you can display with e.g. 'type'.
And if you ever want to copy from the command prompt, if not in quickedit mode, then right click then choose mark then select it then hit ENTER. And to paste right click and choose paste.
An further additional point is
Apparently there are bugs in chcp 65001 where some batch files won't run and maybe some C programs won't work either. How to use unicode characters in Windows command line? And i've even seen the c sharp compiler crash when cmd is in codepage 65001 (though one may blame the c sharp compiler, one could also blame 65001) Why is csc.exe crashing when I last left the output encoding as UTF8?
Note- an earlier revision of this answer had some command line examples but they were unnecessarily complex. I might at some point add some commands that demonstrate what I have been describing but it's fairly trivial.
/u is for UTF-16LE, not UTF-8. This is why saving the file as UTF-16LE (what Windows/Notepad misleadingly calls "Unicode") and running with /u works, in as much as it does.
UTF-8 should be achievable with chcp 65001, but there are some nasty low-level bugs in the Microsoft C Runtime for this code page, which makes some apps unreliable and some not run at all.
So yeah, I'm sorry, but UTF-8 is a second-class citizen under Windows. Anything that uses the 'ANSI' interfaces for IO, including anything that uses the C standard IO library, including the Command Prompt, won't be able to cope with it properly.
The only reliable way to get Unicode output in Command Prompt is to use the Windows-specific WriteConsoleW interface to push Unicode strings directly. Unfortunately as this is not available cross-platform, many tools won't use it.
In any case, even when you've got the encoding right, you still have to have a font in the Command Prompt that contains the characters you want. I believe this is why you still aren't getting Hebrew in the /u+UTF-16LE route.
Summary: Command Prompt + non-ASCII == almost certain fail. Give up and find some other interface you can use that supports Unicode better.
You should convert file.txt to UTF-16(Little Endian) before type file.txt
Reference: What encoding/code page is cmd.exe using?
I presume you mean "Lucida Console" when you say "Lucida".
Using the charmap application I couldn't find any Hebrew characters in the font. I don't know if the font was more capable in earlier versions of Windows, but in Windows 7 there appears to be nothing outside of the European characters.
My system also has Lucida Sans Typewriter which does include the Hebrew characters. Unfortunately the Cmd window doesn't show it as a choice. You need to edit the registry to open up more choices, as shown in this question on SuperUser: https://superuser.com/questions/5035/how-to-change-the-windows-console-font
P.S. I have been unable to verify this solution because Windows is being difficult. See https://superuser.com/questions/390933/how-to-add-a-font-to-the-cmd-window-choices-in-windows-7-64-bit
How to get an Hebrew enabled XP installation?
First of all, this is about an XP home SP3, Hebrew enabled. By that I mean it is a standard XP US installation, or so I believe, with the addition of Hebrew capabilities for keyboard and display. I believe every XP CD can install such a system. In particular, I believe the following is all that is needed for such a system:
Control panel -> Date, Time, Language and Regional Options -> Language and Regional Options -> in Language tab:
1) Click Details and add an Hebrew keyboard.
2) mark with a V the Install files for complex script and right-to-left languages (including Thai) option.
Control panel -> Date, Time, Language and Regional Options -> Language and Regional Options -> in Advanced tab:
Accept, mark with a V, 10004 (MAC - Arabic) and 10005 (Mac - Hebrew). Not sure if Arabic is a must have here.
Now to the cmd console
One has to explicitly add Courier New fonts to the console fonts registry, as described earlier. Otherwise, explicit Hebrew fonts will not be displayed.
Now when cmd console is opened, all there is to do in order to input Hebrew characters is to enable the Courier New fonts, and change the keyboard to an Hebrew mode. Having Windows scroll the languages it has for the keyboard is easy. Either repetitive pressing of left Alt combined with left shift keys, or with the mouse.
As an aside, a dir command will show file names that have Hebrew characters. However, one can't just issue a
dir file_name
and see the usual output if the file begins with a Hebrew letter. It must be
dir *file_name
I assume the asterisk character adds the BOM unicode character.
One can also open Notepad, input Hebrew characters, save the file as UTF8, and run the following in the console commands:
chcp 65001
type that_Notepad_file_I_saved
Saving the file as UTF8 is done on Notepad save screen.