Author atagar1
Recipients atagar1
Date 2008-12-30.22:57:41
SpamBayes Score 0.000156437
Marked as misclassified No
Message-id <1230677862.93.0.319255171122.issue4787@psf.upfronthosting.co.za>
In-reply-to
Content
Hi, in switching to Python 3.0 I've run into an issue with displaying
Unicode characters via curses. In Python 2.x a simple hello-world looks
like:

#!/usr/bin/python
# coding=UTF-8

import curses
import locale

locale.setlocale(locale.LC_ALL,"")

def doStuff(stdscr):
  message = u"hello わたし!"
  stdscr.addstr(0, 0, message.encode("utf-8"), curses.A_BLINK)
  stdscr.getch() # pauses until a key's hit

curses.wrapper(doStuff)

This works. However, when I try to come up with an equivalent for Python
3.0:

#!/usr/bin/python

import curses
import locale

locale.setlocale(locale.LC_ALL,"")

def doStuff(stdscr):
  message = "hello わたし!"
  stdscr.addstr(0, 0, message, curses.A_BLINK)
  stdscr.getch() # pauses until a key's hit

curses.wrapper(doStuff)

It fails (printing gibberish to the console). It seems that the problem
is that the curses module isn't respecting the system's preferred
encoding (utf-8) which was set via the setlocale function (as per
instructions at
http://docs.python.org/dev/3.0/library/curses.html#module-curses).

My apologies in advance if this is my mistake. Cheers! -Damian
History
Date User Action Args
2008-12-30 22:57:43atagar1setrecipients: + atagar1
2008-12-30 22:57:42atagar1setmessageid: <1230677862.93.0.319255171122.issue4787@psf.upfronthosting.co.za>
2008-12-30 22:57:42atagar1linkissue4787 messages
2008-12-30 22:57:41atagar1create