I've asked here but I'm pretty sure I won't get an answer.
code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, time, random, copy, pprint
import termios, tty, fcntl
import thread, curses
import locale
def curses_main(stdscr, code):
curses.curs_set(0)
stdscr.addstr(2, 0, "Coordonnées")
stdscr.refresh()
# (1) = délai d'attente de 1/10 ème de seconde :
curses.halfdelay(1)
while True:
try:
c=stdscr.getch()
except:
c=-1
if 0<c<256:
if chr(c) in 'Qq':
break
def main():
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()
curses.wrapper(curses_main, code)
if __name__ == '__main__':
main()
Error: I thought found it: it's written everywhere to begin with that code:
locale.setlocale(locale.LC_ALL, '')
so i tried with that and it worked:
locale.setlocale(locale.LC_ALL, 'fr_FR')
=> force it to French language
... it worked but only for the accents. If i try to print line drawing chars:
stdscr.addstr(20,20, "─ │ ┌ ┘ ┐ └ ├ ┤ ┬ ┴ ┼ ═ ║ ╔ ╝ ╗ ╚ ╠ ╣ ╦ ╩ ╬")
gives me:
M-b~T~@ M-b~T~B M-b~T~L M-b~T~X M-...
what is head banging is that vim displays properly those chars. So it seems like it comes... from python? From my Windows/cygwin/mintty that works:
env | grep -i lang
LANG=C.UTF-8
if I force encoding at home in my Windows/cygwin/mintty that doesn't work:
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
this doesn't work.
Any idea where I could look? python seems to override properly the locale settings... the console is properly configured, and the fonts can display line drawing chars, because I see them with vim. So thinking more about it, it may be either a problem of python or a problem of curses...
It's solved. here's what I did: I re-installed cygwin then repacked my python program at work, a re-downloaded it then re-installed minnty 0.9.5.1 (mintty-0.9.5-cygwin17.zip) and it works now. Strange.