43

I have installed the new bash shell on windows 10. I'm using it together with ZSH. However, none of the utf8 characters work, they appear as square blocks. How do I enable utf8 character encoding in the shell as default? Is that possible?

  • 7
    If each character appears as one square block, then UTF-8 already works; it's the font that lacks Unicode support. – user1686 Aug 4 '16 at 4:53
  • use chcp 65001 to change codepage to UTF-8 and change the font to Consolas – phuclv Aug 4 '16 at 7:04
  • I switched to the SimSun-Ext B font and all of the characters are displaying correctly. – Ryan Foley Aug 4 '16 at 20:50
  • 6
    @grawity I was using uubntu mono and now switched to consolas. Instead of an empty square box I get a square box with a question mark inside. I also tried the chcp suggestion but it's already set to UTF-8 encoding when I checked the properties. – Ortix92 Aug 6 '16 at 19:30
  • 2
    I would like to point out that this issue is still not solved and that I still can't display unicode utf8 characters properly using ZSH – Ortix92 Apr 7 '17 at 14:07
13

To add to Doctorj's answer, there are a couple fonts that are installed by default that you can use (on Windows 10 bash shell).

Tested languages: Bulgarian, Ukrainian, Chinese Simplified, Chinese traditional, Danish, French, German, Italian, Japanese, Kazakh, Korean, Macedonian, Mongolian, Norwegian, Polish, Portuguese, Russian, Serbian, Spanish, Swedish.

The following default fonts display all observed characters:

  • MS Gothic
  • NSimSun
    • Doesn't appear to display all of Kazakh.
  • SimSun-ExtB (raster font) - My recommendation

Both MS Gothic and NSimSun

  • Spaces out non-Latin non-CJK (Chinese, Japanese, Korean) languages (Macedonian, Kazakh, Bulgarian).
  • Has an odd vertical offset on accented Latin characters (á,é).
  • Didn't display at least one Macedonian character.

SumSun-ExtB (raster font):

  • There's a warning message saying that Raster fonts may not display well.
  • Most characters are displayed darkly (could be a problem with low screen brightness).
  • Non-ASCII characters are bright, in comparison to ASCII characters (possible solution, use the bold option).
  • Characters of all languages close together (easier to see spacing between words).
  • Seems more reliable for non-Latin non-CJK languages.

With any of these fonts, both Command Prompt and PowerShell, weird things happen when you click on non-ASCII characters, though it goes back to normal when you highlight the text.

To install a font: Note that you need to change the font for the Windows shell you're using, such as the Command Prompt or PowerShell, not the Linux way through bash. This link describes which fonts can be used on the Command Prompt (monospace fonts, and how to install and select a font for Command Prompt): Add fonts to the Command Prompt

  • Bring up Registry Editor (run "regedit")
  • Find the folder HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
  • Right click (or Edit) -> New -> String Value
  • Name the font with one more 0 than the last one (such as "000").
  • Right click the entry and select "Modify..."
  • Enter the name of the font or OTF file (without .otf).

For information on installing fonts through the command line on Windows, see this question and answers.

  • I tried installing "Source Code Pro" but it didn't appear in the fonts for me.
  • I installed DejaVu Sans Mono and it works for most languages but doesn't work at all for CJK.
  • I installed Google's Noto monospace font, and it worked, but not for CJK. Also, they specifically say they don't have monospace support for CJK.
  • I installed Google's Inconsolata, and it wasn't worth the try.
  • I installed GNU FreeFont (FreeMono), and it worked, but not for CJK.
  • I gave up and went back to SimSun-ExtB.

(Note: I don't have enough reputation yet to post the links).

| improve this answer | |
13

Right click on the title bar at top of the bash window, choose the entry properties. In the opening window is a tab where you can change the font. I changed the Font to "Source Code Pro" and size 14.

Looks good and all utf-8 characters are working.

| improve this answer | |
  • That's the true answer. You can choose font whatever you like that support UTF8. I installed Menlo and then forgot to change it in bash options, honestly didn't even thought about it. – StalkAlex Apr 18 '17 at 12:50
  • 3
    Please note that I've tried all default options in windows (including Source Code Pro) and the checkmark character (✔) only worked for me with the "DejaVu Sans Mono" font suggested by @user3599934 ! – Sevron Aug 18 '19 at 9:25
10

You can try DejaVu Sans Mono - it works for me.

| improve this answer | |
  • 11
    While this may be the solution to the OP's problem, it's more a hint than a high quality answer. It may be improved by giving instructions on: 1) how to change font for Windows 10 Bash terminal; 2) how to install the said font (unless it's in every Windows 10 by default – I'm on Linux, I don't know). – Kamil Maciorowski Aug 23 '16 at 21:50
  • 1
    I used Ubuntu Mono before and had the problem with it. DejaVu Sans Mono solved the issue. – smonff Feb 6 '18 at 17:10
0

This is really more of a comment than an answer, but since SE doesn't allow me to comment...

You haven't provided enough information. Unicode provides over a million possible characters, of which over 100,000 have been defined. (The remaining ones are for when we contact extraterrestrials, or more likely for Earthlings' writing systems that haven't been encoded yet.) These are divided among about 150 scripts: Latin, Cyrillic, Arabic, Chinese... No font is going to supply glyphs (pictures of characters) for all those characters. (There are one or two that supply a box with the code point inside, but that's not what you want.)

As grawity said over two years ago, if you're getting a box where you expect a single character, then your application already is displaying Unicode (presumably the UTF-8 encoding of Unicode). What you lack is a font that supplies glyphs for whatever scripts you want to display. If you're displaying Russian, you'd want a font with Cyrillic characters; if you want to display Chinese, then you need a font with those characters. (Most such fonts will also display Latin characters--the kind we use for English--but not necessarily pretty.)

So my question for you is: what script are you trying to display? Until we know that, all answers will be guesses.

BTW, there are some scripts that are quite complicated, and only some programs will display them correctly, even if you do have the right font. Among these are Burmese, some Indic scripts (Devanagari, for example), and Arabic (which is written right-to-left, and has characters that should be displayed differently depending on adjacent characters).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.