Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display japanese Kanji inside a cmd window under windows?

I have an english Windows 2003 server with asiatic language support activated. The two only fonts available for the command window (cmd settings) are raster and lucida console. Neither the one nor the other display the Kanji correctly (displayed as question mark).

Is there a solution to get them displayed? Is there some transformation I must do in my application before writing out to the console?

I am writing UTF8 out at the moment, what works well also for some non ASCII characters (like öäüß). The source code writing to the console has the correct data (the Kanji can be viewed in the debugger correctly). If it matters, I am writing the app in C#.

EDIT: I found this link which explains the issues behind the problem and presents a solution (involving native calls) for C#. This shall work well with .NET 4.5 (untested by me)

like image 715
jdehaan Avatar asked Sep 23 '10 16:09

jdehaan


People also ask

Is there a kanji font available for the command window?

The two only fonts available for the command window (cmd settings) are raster and lucida console. Neither the one nor the other display the Kanji correctly (displayed as question mark).

How to display Japanese characters in command prompt with English OS?

This is regarding display of Japanese characters in Command prompt with English OS. We are facing trouble, where in Japanese characters are being displayed as ??. Open command prompt and execute “Dir “command after traversing to D:\Test. Japanese folder will show up as ?? or ..or Garbage.

Is there a way to write kanji in the console?

Without chcp, the console will be using the Windows installation's default code page, in this case cp1252, and writing in kanji will be impossible even if the console font you're using has glyphs for it. If you want to write Unicode to the console reliably you would have to use character-based interfaces like wprintf. Show activity on this post.

How do I change the language of my program to Japanese?

Click the language symbol in the bottom right of the task bar next to the time and select "language preferences". In the opening window, select "Additional date, time and regional settings" at the bottom. Select "Region". In the "Region" window select "Administrative" and then "change system locale" for non-unicode programs to Japanese.


4 Answers

If you find a font that will display the Kanji character set, you can add that font to the cmd Settings by adding values under this Registry key:

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

Values:

Name: 00
Data: Consolas

I've done this before but found this reference on SuperUser: https://superuser.com/q/55318

Hope this helps

like image 66
paludarium Avatar answered Oct 06 '22 18:10

paludarium


How is your application writing output? The C byte-based stdio calls like printf won't support UTF-8 on Windows unless you have specifically set the console to use UTF-8 encoding by saying chcp 65001 && somecommand (and even then there are problems).

Without chcp, the console will be using the Windows installation's default code page, in this case cp1252, and writing in kanji will be impossible even if the console font you're using has glyphs for it.

If you want to write Unicode to the console reliably you would have to use character-based interfaces like wprintf.

like image 38
bobince Avatar answered Oct 06 '22 16:10

bobince


This is how I can got Chinese input/output in cmd.exe running on Windows 7 Pro English Version.

  1. Install console2, which is a front-end to cmd.exe (and other shells).

  2. After installation, follow the instruction here

    • Delete key "Console2 command window" in registry
    • Import the following data into windows registry:

    • For Chinese(中文) Windows XP & Vista:

      Windows Registry Editor Version 5.00
      
      [HKEY_CURRENT_USER\Console\Console2 command window]
      "CodePage"=dword:000003a8
      "FontSize"=dword:000a0000
      "FontFamily"=dword:00000036
      "FontWeight"=dword:00000190
      "FaceName"="細明體"
      "HistoryNoDup"=dword:00000000
      
    • For Japanese(日本語) Windows XP & Vista:

      Windows Registry Editor Version 5.00
      
      [HKEY_CURRENT_USER\Console\Console2 command window]
      "CodePage"=dword:000003a8
      "FontSize"=dword:000a0000
      "FontFamily"=dword:00000036
      "FontWeight"=dword:00000190
      "FaceName"="MS 明朝"
      "HistoryNoDup"=dword:00000000
      
  3. You may or may not have to change the font. Initially I had the font set to @NimSum, and the Chinese characters came out rotate 90 degrees. Then I switched to NimSum (without the @) and it came out correctly. Then just out of curiosity I switched to Consola and yet I can still see the Chinese Characters. So not sure if you actually have to set the font or not.

like image 3
crusherjoe Avatar answered Oct 06 '22 16:10

crusherjoe


Consolas (even on Windows 10) does not display Japanese characters correctly in a console; I checked the font in Character Map and it simply doesn't have glyphs for any SE Asian languages. You need to set your console font to MS Mincho or a similar Asian-supporting font to show Japanese characters. This will also change backslashes to yen symbols which is a standard thing on Japanese systems. You don't need to change your code page or locale settings, but you will need to at least install Japanese language support to get the Japanese fonts installed. On NT5 systems like Windows Server 2003 and Windows XP, there's a checkbox somewhere in the regional and language options for it; on NT6 (Vista and later) you can just add the Japanese IME and it'll install the required files.

like image 1
Jody Bruchon Avatar answered Oct 06 '22 18:10

Jody Bruchon