473,671 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python+ncurses: I can't display accents


Hello.

I'm trying to display french characters (è -- that's e grave -- or à --
agrave) in python 2.5, with the ncurses wrapper that comes it, and I can't.
My locale is set correctly (fr_FR.iso88591 5), and my terminal (rxvt-unicode)
is able to display those chars.

What am I missing?

Thanks.

--
Fabrice DELENTE
Jan 26 '07 #1
14 3363
On 2007-01-26, Fabrice DELENTE <fd******@mail. cpod.frwrote:
I'm trying to display french characters (è -- that's e grave --
or à -- agrave) in python 2.5, with the ncurses wrapper that
comes it, and I can't. My locale is set correctly
(fr_FR.iso88591 5), and my terminal (rxvt-unicode) is able to
display those chars.
What have you tried?

--
Neil Cerutti

--
Posted via a free Usenet account from http://www.teranews.com

Jan 26 '07 #2
What have you tried?

I've tried

stdscr.addstr(0 ,0,"aéïoù")

or

stdscr.addstr(0 ,0,"leçon")

The ASCII chars show correctly, but the accented characters don't, so I see
'ao' or 'leon' on the screen.

The term in which I display is 8-bit-able, so the problem is either on
ncurses side, or on python side.

I have

#!/usr/local/bin/python
#coding: iso8859-15

at the top of my python file.

--
Fabrice DELENTE
Jan 26 '07 #3
On 2007-01-26, Fabrice DELENTE <fd******@mail. cpod.frwrote:
>What have you tried?

I've tried

stdscr.addstr(0 ,0,"aéïoù")

or

stdscr.addstr(0 ,0,"leçon")

The ASCII chars show correctly, but the accented characters
don't, so I see 'ao' or 'leon' on the screen.

The term in which I display is 8-bit-able, so the problem is
either on ncurses side, or on python side.
What happens when you try this?

stdscr.addstr(0 ,0, u"leçon".encode ('iso8859-15'))

I don't really expect it to work, but if anything will, that is
it. Curses supports only ASCII and a some special symbol codes
defined by curses.
I have

#!/usr/local/bin/python
#coding: iso8859-15
Be sure to write your non-ASCII strings as unicode literals, and
then encode them just before displaying or storing them
somewhere.

--
Neil Cerutti

--
Posted via a free Usenet account from http://www.teranews.com

Jan 26 '07 #4
What happens when you try this?
stdscr.addstr(0 ,0, u"leçon".encode ('iso8859-15'))
I don't really expect it to work
And it doesn't...

As support for 8-bit (and even unicode) is important for my script, is there
any hope? Should I switch to slang instead of curses?

--
Fabrice DELENTE
Jan 26 '07 #5
Neil Cerutti <ho*****@yahoo. comwrote:
I don't really expect it to work, but if anything will, that is
it. Curses supports only ASCII and a some special symbol codes
defined by curses.
un - no. Curses supports whatever the flavor of curses you have does.
Often that's the 8-bit flavor of ncurses, but the limitation is definitely
in the python configuration.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Jan 27 '07 #6
My system is Linux, and the distribution is Slackware 10.1.

I have

/lib/libncurses.so.5 .4
/lib/libncursesw.so. 5.4

so I even have the wide-chars version available. Any hint on the python
configuration? I didn't find any function that would allow the unrestricted
display of 8-bit chars.

--
Fabrice DELENTE
Jan 27 '07 #7
On 2007-01-27, Thomas Dickey <di****@saltmin e.radix.netwrot e:
Neil Cerutti <ho*****@yahoo. comwrote:
>I don't really expect it to work, but if anything will, that
is it. Curses supports only ASCII and a some special symbol
codes defined by curses.

un - no. Curses supports whatever the flavor of curses you
have does. Often that's the 8-bit flavor of ncurses, but the
limitation is definitely in the python configuration.
Thanks for the clarification. I was going by the some Python
documentation, but I did notice contradictory information in
other discussion. The 8-bit ncurses is supposed to support
iso-8859-1 through iso-8859-15, i.e., all the byle encodings. I
don't know why Python's bindings don't work.

--
Neil Cerutti
Jan 27 '07 #8
To really be sure that the problem is when I use python, I tried in C:

#include <stdio.h>
#include <ncurses.h>

int main(void)
{
initscr(); /* Start curses mode */
// printw("àéïoù") ; /* Print Hello World */
addstr("àéïoù") ; /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */

return(0);
}

and both my tries (with printw, or with addstr) showed the 8-bot chars
correctly.

--
Fabrice DELENTE
Jan 27 '07 #9
Incidentally, I noticed something about the environment: in my script, I use
the LINES and COLUMNS environment vars that are set in my shell:

columns=int(os. environ.get("CO LUMNS"))
lines=int(os.en viron.get("LINE S"))

In the shell, I get

$ echo $LINES $COLUMNS
89 199

but python doesn't get these values. I have to start the script with

$ LINES=$LINES COLUMNS=$COLUMN S ./sort_entries.py

How come?

--
Fabrice DELENTE
Jan 27 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9206
by: Dominik Kaspar | last post by:
hello i'm wondering if i'm just too stupid for python or if i've missed something fundamentally important of its semantics. Why does the following program result in the TypeError: print_it() takes exactly 1 argument (2 given)? I don't see any function passing or receiving 2 arguments here... am i blind? import threading
10
2883
by: Dan Williams | last post by:
Ummmm... This is weird. Sorry if it's known about (how can it NOT be, I wonder?) but I haven't seen any reference to it anywhere. I'm running the latest Python (2.3.3) on Windows XP Pro, i386 architecture. Fire up python or whatever. Do this: Result:
0
1078
by: Harald Massa | last post by:
TOD DURCH ÜBERFRESSEN (Dead through overmunch) Python verschluckt sich an Kälbchen (Python chokes as little calf) http://www.spiegel.de/panorama/0,1518,307166,00.html
2
4089
by: Aggelos I. Orfanakos | last post by:
Hello. Under Gentoo Linux, I issue: $ python timeit.py python: can't open file 'timeit.py' $ ls -al /usr/lib/python2.3/timeit.py -rw-r--r-- 1 root root 9833 Oct 19 02:17 /usr/lib/python2.3/timeit.py But if I specify the full path, it works:
4
1552
by: silasju | last post by:
Hello people! I think it is my first message here. Well, I would go to start a Delphi database program, but now my client want a program that runs in Linux. So I want to know your opinion: what best language/IDE I can use for my purposes? I need mainly: MySQL or Potsgree SQL ***remote connection***(it's the most important). GUI interface. Report generator. Barcode printing.
5
1621
by: Dr. Who | last post by:
So here it is: handle unbuffered output from a child process. Here is the child process script (bufcallee.py): import time print 'START' time.sleep(10) print 'STOP' In Perl, I do: open(FILE, "python bufcallee.py |");
0
1498
by: ycollet | last post by:
Hello, I'm trying to write a program to send python statements to a python server via tcp and then get back results via a tcp connection. It nearly works ... but I'm totally lost with the embedded dictionary (I'm quite new to python). The first part of the server start the python interpreter via Py_Initialize() and then waits for python statements. To send command, I get some strings and evaluate them through PyRun_String.
2
3463
by: enquiring mind | last post by:
-learning python with limited knowledge of linux. -get error msg 21 "file or directory does not exist" -running Suse linux 10. -haven't had a problem before - rebooted several times. -python opened in shell/terminal program Konsole window like this user1@linux!~ - shell - Konsole Sessions View Bookmark Settings Help -first line in window gives me a linux prompt:
2
2066
by: psbasha | last post by:
Hi all, I am back again!!!. Whether Python can be used for Geograpical Information System (GIS)?.If so,can anybody help me which module of python it falls. Is thier any possible links which help me in using Python for GIS? Thanks PSB
0
8478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8599
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2813
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.