python - Cannot make warning sign visible on OSX Terminal and ncurses -
this simple program on osx 10.6.8, python 3.4, terminal.app , font menlo prints 3 unicode characters: smiley, warning sign, , radioactive symbol, or maybe should should print, because in fact first , last. warning sign not there.
from curses import wrapper def main(stdscr): # clear screen stdscr.clear() in range(1, 11): stdscr.addstr(i, 0, '\u263a \u26a0 \u2622'.encode("utf-8")) stdscr.refresh() stdscr.getkey() wrapper(main)
additionally, if open font book, apparently menlo have glyph warning sign, puzzles me if go edit -> special characters, select warning sign, , click insert, warning sign @ command prompt. using print() shows warning sign.
what's going on?
edit: apparently it's bug in osx libc library. see here
how ncurses output astral plane unicode characters
i tried compiling small program wcinfo
sbo@sbos-macbook:~$ ./wcinfo 26a0 code 26a0: width -1 sbo@sbos-macbook:~$ ./wcinfo 263a code 263a: width 1 punct graph print
so, warning sign, -1, means non-printable character. so, osx problem, , fundamental one.
when run on mac os x 10.10 (yosemite) terminal using lucida console font, output shown below:
$ printf "%s\n" u+263a u+0020 u+26a0 u+0020 u+2622 | unicode-utf8 ☺ ⚠ ☢ $ printf "%s\n" u+263a u+0020 u+26a0 u+0020 u+2622 | unicode-utf8 | odx 0x0000: e2 98 ba 20 e2 9a a0 20 e2 98 a2 0a ... ... .... 0x000c: $ printf "%s\n" u+263a u+0020 u+26a0 u+0020 u+2622 | unicode-utf8 | utf8-unicode (standard input): 0xe2 0x98 0xba = u+263a 0x20 = u+0020 0xe2 0x9a 0xa0 = u+26a0 0x20 = u+0020 0xe2 0x98 0xa2 = u+2622 0x0a = u+000a $
the program unicode-utf8
, utf8-unicode
, , odx
home-brew programs (the unicode ones not particularly elegant), allow me analysis work unicode. and, @ least on computer, 3 symbols show up. when not separated spaces, triangle , radiation symbols overlapped on screen (unlike in browser), why added spaces:
☺⚠☢
so, suggest looking hard @ output of script show. might seeing encoding problem, or curses library may not aware of utf-8, or …
when run python 2, get:
\u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622 \u263a \u26a0 \u2622
when run python 3, get:
☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢ ☺ ☢
this means can reproduce problem, seems problem in python rather in terminal.
i ran:
$ python3 so.26919799.py > py3.output $ odx py3.output
the relevant part of output is:
0x1d60: 20 20 20 20 20 20 20 1b 5b 36 35 3b 31 48 20 20 .[65;1h 0x1d70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 * (5) 0x1dd0: 20 20 20 20 20 20 20 20 20 20 20 08 20 08 1b 5b . ..[ 0x1de0: 34 68 20 1b 5b 34 6c 1b 5b 48 0a e2 98 ba 20 20 4h .[4l.[h.... 0x1df0: 20 e2 98 a2 0d 0a e2 98 ba 20 20 20 e2 98 a2 0d ........ .... 0x1e00: 0a e2 98 ba 20 20 20 e2 98 a2 0d 0a e2 98 ba 20 .... ........ 0x1e10: 20 20 e2 98 a2 0d 0a e2 98 ba 20 20 20 e2 98 a2 ........ ... 0x1e20: 0d 0a e2 98 ba 20 20 20 e2 98 a2 0d 0a e2 98 ba ..... ........ 0x1e30: 20 20 20 e2 98 a2 0d 0a e2 98 ba 20 20 20 e2 98 ........ .. 0x1e40: a2 0d 0a e2 98 ba 20 20 20 e2 98 a2 0d 0a e2 98 ...... ....... 0x1e50: ba 20 20 20 e2 98 a2 1b 5b 3f 31 6c 1b 3e 1b 5b . ....[?1l.>.[ 0x1e60: 6d 0d 1b 5b 35 34 42 1b 5b 4b 1b 5b 36 35 3b 31 m..[54b.[k.[65;1 0x1e70: 48 1b 5b 32 4a 1b 5b 3f 34 37 6c 1b 38 0d 1b 5b h.[2j.[?47l.8..[ 0x1e80: 3f 31 6c 1b 3e ?1l.> 0x1e85:
the 0x1d60:
indicates byte offset in file. terminal window 110 wide , 65 deep, there lot of blanks being generated output. * (5)
line indicates 5 more lines of 16 blanks. can see data containing bytes e2 98 ba , e2 98 a2, in between there 3 blanks, instead of e2 98 a0 you'd expect. so, translation of alert symbol being mishandled python 3.
Comments
Post a Comment