Wiktor
2014-08-03 22:52:29 UTC
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 and here's
video from modern rewritten (for Atari emulators) version: Kolony 2106
- 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
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 and here's
video from modern rewritten (for Atari emulators) version: Kolony 2106
- 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
--
Best regards, Wiktor Matuszewski
'py{}@wu{}em.pl'.format('wkm', 'ka')
Best regards, Wiktor Matuszewski
'py{}@wu{}em.pl'.format('wkm', 'ka')