Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, January 2, 2016

Unicode characters in Windows command line - how?

Unicode characters in Windows command line - how?


We have a project in 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. 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. Anybody have an idea how to excecute a program and pass it a Unicode command line?

Answer by kgiannakakis for Unicode characters in Windows command line - how?


Try:

chcp 65001  

which will change the code page to UTF-8. Also, you need to use Lucida console fonts.

Answer by User for Unicode characters in Windows command line - how?


Actually, the trick is that the command prompt actually understands these non-english characters, just can't display them correctly.

When I enter a path in the command prompt that contains some non-english chracters it is displayed as "?? ?????? ?????". When you submit your command (cd "??? ?????? ?????" in my case), everything is working as expected.

Answer by vanna for Unicode characters in Windows command line - how?


I had same problem (I'm from Czech Republic). I have English installation of windows and I have to work with file on shared drive. Path to this file include Czech specific characters. Solution that works for me is:

In batch file, change charset page

My batch file:

chcp 1250  copy "O:\VEŘEJNÉ\ŽŽŽŽŽŽ\Ž.xls" c:\temp  

Batch file has to be saved in CP 1250!

note that console will not show characters correctly but it will understand them ...

Answer by Christoforos for Unicode characters in Windows command line - how?


for a similar problem, (my problem was to show utf8 characters from mysql on command prompt), I solved it like this:

  1. I changed the font of command prompt to Lucida. (This step must be irrelevant for your situation. It has to do only with what you see on the screen and not with what is really the character).

  2. I changed the codepage to windows-1253. You do this on command prompt by "chcp 1253". It worked for my case where I wanted to see utf-8.

Answer by Maxim Yefremov for Unicode characters in Windows command line - how?


Check the language for non-Unicode programs. If you have problems with Russian in windows console, then you should set here Russian: Changing language for non-Unicode programs

Answer by user1645765 for Unicode characters in Windows command line - how?


A better cleaner thing to do: Just install the available, free, Microsoft Japanese language pack. (Other oriental language packs will also work, but I have tested the Japanese one.)

This gives you the fonts with the larger sets of glyphs, makes them the default behavior, changes the various windows tools like cmd, wordpad, etc.

Answer by pipepipe0071 for Unicode characters in Windows command line - how?


To make it default, Type chcp 437

Answer by madhav bitra for Unicode characters in Windows command line - how?


Change Code Page to 1252 is working for me, the problem for me is the symbol double doller § is converting to another symbol by dos in windows server 2008

I have used CHCP 1252 and a cap before it in my BCP statement ^§.

Regards, Madhava.B

Answer by S. Hristov for Unicode characters in Windows command line - how?


A quick decision for .bat files if you computer displays your path/file name correct when you typing it in DOS-window:

  1. copy con temp.txt [press Enter]
  2. Type the path/file name [press Enter]
  3. Press Ctrl-Z [press Enter]

This way you create a .txt file - temp.txt. Open it in Notepad, copy the text (don't worry it will look unreadable) and paste it in your .bat file. Executing the .bat created this way in DOS-window worked for m? (Cyrillic, Bulgarian).

Answer by Wernfried Domscheit for Unicode characters in Windows command line - how?


It's is quite difficult to change the default Codepage of Windows console. When you search the web you find different proposals, however some of them may break your Windows entirely, i.e. your PC does not boot anymore.

The most secure solution is this one: Go to your Registry key HKEY_CURRENT_USER\Software\Microsoft\Command Processor and add String value Autorun = chcp 65001.

Or you can use this small Batch-Script for the most common code pages.

@ECHO off    SET ROOT_KEY="HKEY_CURRENT_USER"      FOR /f "skip=2 tokens=3" %%i in ('reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage /v OEMCP') do set OEMCP=%%i    ECHO System default values:    ECHO.  ECHO ...............................................  ECHO Select Codepage   ECHO ...............................................  ECHO.  ECHO 1 - CP1252  ECHO 2 - UTF-8  ECHO 3 - CP850  ECHO 4 - ISO-8859-1  ECHO 5 - ISO-8859-15  ECHO 6 - US-ASCII  ECHO.  ECHO 9 - Reset to System Default (CP%OEMCP%)  ECHO 0 - EXIT  ECHO.      SET /P  CP="Select a Codepage: "    if %CP%==1 (      echo Set default Codepage to CP1252      reg add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 1252" /f  ) else if %CP%==2 (      echo Set default Codepage to UTF-8      reg add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 65001" /f  ) else if %CP%==3 (      echo Set default Codepage to CP850      reg add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 850" /f  ) else if %CP%==4 (      echo Set default Codepage to ISO-8859-1      add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 28591" /f  ) else if %CP%==5 (      echo Set default Codepage to ISO-8859-15      add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 28605" /f  ) else if %CP%==5 (      echo Set default Codepage to ASCII      add "%ROOT_KEY%\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d "chcp 20127" /f  ) else if %CP%==9 (      echo Reset Codepage to System Default      reg delete "%ROOT_KEY%\Software\Microsoft\Command Processor" /v AutoRun /f  ) else if %CP%==0 (      echo Bye  ) else (      echo Invalid choice      pause  )  

Note, the settings will apply only for the current user. If you like to set it for all users, replace line SET ROOT_KEY="HKEY_CURRENT_USER" by SET ROOT_KEY="HKEY_LOCAL_MACHINE"

Answer by Michael for Unicode characters in Windows command line - how?


I got around a similar issue deleting Unicode-named files by referring to them in the batch file by their short (8 dot 3) names.
The short names can be viewed by doing dir /x. Obviously this only works with Unicode file names that are already known.

-Michael

Answer by Steve Barnes for Unicode characters in Windows command line - how?


One really simple option is to install a windows bash shell such as MinGW and use that. enter image description here

There is a little bit of a learning curve as you will need to use Unix command line functionality but you will love the power of it and you can set the console character set to UTF-8. enter image description here

Of course you also get all the usual *nix goodies like grep, find, less, etc.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.