Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; '"""': 0.07; 'error:': 0.07; '(those': 0.09; '8bit%:30': 0.09; 'encode': 0.09; 'filenames': 0.09; 'idea?': 0.09; 'lawrence': 0.09; 'polish': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:characters': 0.09; 'python': 0.11; 'bug': 0.12; 'language.': 0.14; 'windows': 0.15; ';-)).': 0.16; 'codec': 0.16; 'means.': 0.16; 'menu.': 0.16; 'program?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rewritten': 0.16; 'subject:Unicode': 0.16; 'symbols': 0.16; 'unicode.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'command': 0.22; 'programming': 0.22; 'print': 0.22; 'header :User-Agent:1': 0.23; '(by': 0.24; 'subject:problem': 0.24; 'unicode': 0.24; 'skip:" 30': 0.26; 'this:': 0.26; '(for': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'idea': 0.28; 'character': 0.29; "doesn't": 0.30; 'characters': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'too.': 0.31; 'subject:some': 0.31; 'up:': 0.31; 'file': 0.32; '(most': 0.33; 'entirely': 0.33; 'subject:with': 0.35; "can't": 0.35; 'display': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'really': 0.36; '14,': 0.36; 'set.': 0.36; 'version:': 0.36; 'next': 0.36; 'possible': 0.36; 'hi,': 0.36; 'changing': 0.37; 'turn': 0.37; 'being': 0.38; 'problems': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'help,': 0.39; 'support,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'letters': 0.60; 'skip:c 50': 0.60; 'most': 0.60; 'matter': 0.61; 'our': 0.64; 'bottom': 0.67; 'believe': 0.68; 'production': 0.68; 'containing': 0.69; 'url:v': 0.71; 'url:youtube': 0.71; '8bit%:100': 0.72; 'construction': 0.72; 'url:watch': 0.77; 'characters,': 0.84; 'exercise,': 0.84; 'fonts': 0.84; 'messed': 0.84; 'them)': 0.84; '\xe2\x94\x82': 0.84; 'skip:\xe2 30': 0.91; 'skip:\xe2 40': 0.91; 'thing,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: cmd.exe on WIndows - problem with displaying some Unicode characters Date: Mon, 04 Aug 2014 00:20:53 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-24-217-238.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 81 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407108065 news.xs4all.nl 2831 [2001:888:2000:d::a6]:45659 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75628 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 > | """ > | 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 > > 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