Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75628

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: cmd.exe on WIndows - problem with displaying some Unicode characters
Date 2014-08-04 00:20 +0100
References <yxht7c4so8ud.kqpa5p5iv0mp.dlg@40tude.net>
Newsgroups comp.lang.python
Message-ID <mailman.12602.1407108065.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 03/08/2014 23:52, Wiktor wrote:
>
> Hi,
>
> as OO programming exercise, I'm trying to port to Python one of my favorite
> game from early'90 (Atari 65XL/XE) - Kolony (here's video from original
> version on C64 https://www.youtube.com/watch?v=UFycYOp2cbE, and here's
> video from modern rewritten (for Atari emulators) version: Kolony 2106
> https://www.youtube.com/watch?v=eX20Qqqm5eg - you get the idea? ;-)).
>
> OO Design is one thing, but I want to make it look as near as possible to
> the original (those windows-like menus in console window). I tried to use
> 'standard' Unicode characters (I can see that most of my Windows monospaced
> fonts have them) to draw frame around menu. Something like this:
>
>   ┌──────────────╖
>   │ Construction ║
>   │ Production   ║
>   │ Research     ║
>   │ Exploration  ║
>   ├··············╢
>   │ Next turn    ║
>   ╘══════════════╝
>
> (I like the look of double lines on right and at the bottom)
> But when I try to print those characters, I get an error:
>
> | Traceback (most recent call last):
> |   File "E:\Moje dokumenty\python\kolony\menu.py", line 14, in <module>
> |     """
> |   File "C:\Python34\lib\encodings\cp852.py", line 19, in encode
> |     return codecs.charmap_encode(input,self.errors,encoding_map)[0]
> | UnicodeEncodeError: 'charmap' codec can't encode character '\u2556' in position 1
> | 6: character maps to <undefined>
>
> Now I know what that means. Code page that my cmd.exe is using (852)
> doesn't have "╖", "╘", "╢" and "·" symbols. Changing code page to Unicode
> (65001) doesn't really help, because all is messed up:
>   ┌──────────────╖
>   │ Construction ║
>   │ Production   ║
>   │ Research     ║
>   │ Exploration  ║
>   ├··············╢
>   │ Next turn    ║
>   ╘══════════════╝
>      �·········╢
>   │ Next turn    ║
>   ╘══════════════╝
>      ��════════════╝
>      ��═════╝
>      ═╝
> (I believe that's cmd.exe bug with Unicode support, not Python fault)
>
>
> Before I drop entirely this idea of using double lines on right and bottom
> edges, and make it look like this
>      ┌──────────────┐
>      │ Construction │
>      ├--------------┤
>      │ Next turn    │
>      └──────────────┘
> I have to ask - is there a way to make that original concept work? I know,
> that CP437 has symbols "╖", "╢" and "╘", but does not have polish letters -
> and I need to display them too.
> I also know, that cmd.exe can display those Unicode characters (by
> copy/paste them in command line or by listing filenames containing that
> characters), no matter what CP is set. How does it manage to do it? Can I
> exploit that writing my Python program?
> Wiktor
>

There are multiple known problems with cmd.exe and unicode.  A solution 
might be to use powershell, but windows being windows who really knows? :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 00:52 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 09:08 +1000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Christian Gollwitzer <auriocus@gmx.de> - 2014-08-04 22:35 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-04 00:20 +0100
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-03 18:25 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-04 00:29 +0100
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 09:39 +1000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-04 10:14 +1000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-03 17:17 -0700
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-04 01:47 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-03 21:14 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-04 00:06 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 04:39 -0400
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 17:00 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-08-04 17:43 +0200
        Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 18:48 +0200
          Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-05 03:06 +1000
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 19:22 +0200
              Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:43 -0400
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:17 -0400
        Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-04 22:24 +0200
          Re: cmd.exe on WIndows - problem with displaying some Unicode characters Akira Li <4kir4.1i@gmail.com> - 2014-08-05 04:51 +0400
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-05 00:38 -0700
            Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-05 11:39 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris Angelico <rosuav@gmail.com> - 2014-08-05 06:11 +1000
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters giacomo boffi <g@boffi.net> - 2014-08-04 22:53 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-08-04 10:46 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 02:46 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 02:53 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-08-04 12:24 +0200
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-04 05:33 -0500
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 11:04 -0700
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Glenn Linderman <v+python@g.nevcal.com> - 2014-08-04 11:15 -0700
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Grant Edwards <invalid@invalid.invalid> - 2014-08-04 19:30 +0000
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Terry Reedy <tjreedy@udel.edu> - 2014-08-04 15:25 -0400
  Re: cmd.exe on WIndows - problem with displaying some Unicode characters Tony the Tiger <tony@tiger.invalid> - 2014-08-05 20:26 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Grant Edwards <invalid@invalid.invalid> - 2014-08-05 20:41 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters Wiktor <look@signature.invalid> - 2014-08-06 00:16 +0200
      Re: cmd.exe on WIndows - problem with displaying some Unicode characters Tony the Tiger <tony@tiger.invalid> - 2014-08-06 18:27 +0000
    Re: cmd.exe on WIndows - problem with displaying some Unicode characters wxjmfauth@gmail.com - 2014-08-05 23:30 -0700

csiph-web