Outputting unicode characters in windows terminal

前端 未结 4 2173
Happy的楠姐
Happy的楠姐 2020-12-06 19:06

Over the past week I\'ve been working on a roguelike game in C++ along with a friend. Mostly too learn the language.

I\'m using:

  • pdcurses
  • Wind
4条回答
  •  隐瞒了意图╮
    2020-12-06 19:56

    The problem is that I need to force the terminal to switch to a more unicode-rich font face. Is there a cross-platform way to do this? is there even a windows specific way to do this?

    I had a look for this, but couldn't find a Windows API call to do it (which may just mean I didn't find it, of course). I would not expect to find a cross-platform way to do it.

    The best solution I can think of is to launch the console using a specially constructed Shell Link (.LNK) file. If you read the file format documentation, you'll see that it allows you to specify a font.

    But your problems don't end there. A Western locale install of Windows provides Lucida Console, but that font only provides a limited subset of graphemes. I assume that you can output/input Japanese text in the console on a Japanese Windows PC. You'd need to check what is available on a Japanese Windows if you wanted to be sure it would work there.

    Linux (Ubuntu, at least) seems to have much better support here, using UTF-8 and providing a font with broad grapheme support. I haven't checked other distros to see what the story is there, nor have I checked how fonts are resolved in the terminal (whether it's an X thing, a Gnome thing or whatever).

提交回复
热议问题