How to change the console output into English on Hungarian system - windows

Windows vista with Hungarian.
I want to change the console output into English.
'chcp 437' is no use, the output is still in Hungarian.
Any other method for this?
for example, I want to get the volume info via batch file.
chcp 437
echo list volume >list.txt
diskpart /s list.txt > result.txt
Now, I want the content of result.txt is in English, but it is still in Hungarian.

I believe the problem is that the program does not read the Windows locale setting (which is English for unicode) and starts displaying the messages in Hungarian while you have switched the console to English (e.g. there are no glyphs for Hungarian characters). I am not sure if the program you are using can speak English at all.

Related

How to print chinese characters to the windows console correctly?

What I want to do is to print Chinese log messages to the windows console.
I did surveying the google and knew that it's related to Chinese font.
But when after setting the Chinese font, at this time incorrect Chinese characters were printed.
I hope to teach me how to solve this if you have some experiences before.
You can simply reproduce this situation.
Create new txt file and write to this "echo '你好!'",and save this file as 'test.bat'
Run this bat file in the console.
What I want to do is print this Chinese character correctly.
All you need to do is set the appropriate code page in the console before running the bat file containing Chinese text. Code page 936 is for simplified Chinese, so call chcp 936, and then run test.bat.
In my case (on Windows 10) I didn't need to worry about the font being used, since chcp 936 automatically changed the font to one that can render Chinese characters: NSimSun.
Depending on your requirements, it might be preferable to include the call to chcp 936 at the start of the bat file instead.

Is there a way to specify paper tray when using the lpr command to print PDF files through Windows batch scripting?

I am trying to set up an automatic printing solution on a Windows 2012 R2 Server.
So far I have written a .bat file that loops through and prints all pdf files that are in a folder. The main command looks something like this :
lpr -S 100.100.100.100 -P printQ %%F
(Where %%F is the file name)
Looking at Microsoft's documentation on this page, there doesn't seem to be anyway to specify the printer tray.
I could specify the printer tray through the control panel, but the batch script needs to dynamically assign different paper trays for different files.
I've come across some commercial command line printing solutions that use lpr and that are able to specify paper tray. Would I be correct to assume that it is therefore possible to dynamically specify paper tray using lpr?
I worked around the lpr limitations by creating 2 instances of the same printer in the control panel > Devices and Printers. And setting up both instances with a different paper tray source.
The lpr command seemed to ignore different printers set using the "-P" argument, probably because the "-S" argument was the same IP for the same printer. So I ended up using the PDF-XChange command line printing function instead.
"C:\Program Files\Tracker Software\PDF Viewer\PDFXCView.exe" /print:printer=!printer! "%%F"
I'm not sure if this is the best solution, but it works for now.

how i can display arabic letters in cmd

can any one give my solution to display the arabic letters in cmd
i tried to use chcp 1256 and chcp 62001 in cmd but it does not show the arabic letters correctly
but when i search in the internet i found someone who said there is solution but it needs some files in windows 95 or windows 98 but i am not sure if he lying or not
if there is files to display the arabic letters in cmd in windows 95 or windows 98 can any one upload those files to me or give me solution to display arabic letters in cmd
As mentioned here, it is not possible to write arabic characters in the console even if you change the codepage or the font because it is not supported in the cmd prompt as a consequence it will not be displayed correctly.
update:
Even if you try to use third party monospaced fonts like this that will not show characters as expected.

In Win7, Unicode/ UTF-8 text file: gibberish on Windows console (Trying to display hebrew)

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.

Change CodePage in CMD permanently?

My Windows cmd CodePage is now under 65001.
Since I was doing some Android stuff and need to use console log, but forget how changing it now.
When using chcp 437 to change the CodePage back, it works. But if I start a new cmd window, it goes back.
How to do the chcp thing to make it pernament?
In the 1809 build of Windows 10 I've managed to permanently solve this by going to the system's Language settings, selecting Administrative language settings, clicking Change system locale... and checking the Beta: Use Unicode UTF-8 for worldwide language support box and then restarting my pc.
This way it applies to all applications, even those ones that I don't start from a command prompt!
(Which was necessary for me, since I was trying to edit Agda code from Atom.)
Here I found a better solution:
Start -> Run -> regedit
Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
Add new String Value named: Autorun
Change the value to 'chcp 437'
Create a start up batch file that includes all the commands you want.
Then edit the registry to point to your start up file.
http://technet.microsoft.com/en-us/library/cc779439%28WS.10%29.aspx
c:\startup.cmd
#echo off
chcp 437
HKLM\SOFTWARE\Microsoft\Command Processor
AUTORUN="C:\startup.cmd"
Command prompt code page always change back to the default 437 if you just use chcp 850 in cmd to change the active language code (850 = Multilingual (Latin I)).
My system default language is set to English (437) although I'm Brazilian (language code 850).
Once I need to show some special characters such as ã, õ, ç, I found that at Windows 10, under All Settings > Time & Language > Region & Language there is (at the top right corner) a link for Related settings - Additional date, time & regional settings. From there you'll be redirected to Control Panel\Clock, Language, and Region. Click again on Region > Change Location and at the window Region, at the tab Administrative, change the Language for non-Unicode programs by clicking the button Change system locale and choosing some other that uses the code you need (In my case, Portuguese (Brazil) = code 850). Restart Windows and check if your command prompt is now set to the new language code (type chcp in cmd). For me, it solved the problem.
There is also a Latin (Word) option on the list that I suppose is also code 850.
Setting the default CMD/shell Codepage can be neatly done using the following command:
REG ADD HKCU\Console\%SystemRoot^%_system32_cmd.exe /v CodePage /t REG_DWORD /d 437
This will make the codepage 437 your default, but ONLY in the cmd/shell, meaning the rest of the OS is safe and the boot environment ist untouched.
Instead of always changing the codepage whenever the cmd opens, the cmd will open in the specified codepage from start.
If you wish to edit it manually using regedit.exe, beware that you have to set the codepage value in 'decimal' (use the radio-buttons for selecting decimal or hex input).
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage
You can edit code page value permanently by editing OEMCP key value in windows in above reg key value
Warning: Don't do it, it will make your system unable to boot. See related.

Resources