[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readline 5.0 bug with utf-8 characters + editing ?

From: Chet Ramey
Subject: Re: readline 5.0 bug with utf-8 characters + editing ?
Date: Sat, 29 Jan 2005 11:41:08 -0500
User-agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)

Danny Milosavljevic wrote:

Thank you for bash and readline :)
I use it every day...

However, I wonder if this is a known problem:

I do not believe that this is a readline problem.

I use readline 5.0, and try the following:

/* gcc -o testreadline testreadline.c -lreadline
-ltermcap */
/* readline 5.0 */
/* set locale to some UTF-8 locale */

By this, I assume you mean you sent and export LANG or a similar
environment variable.

/* run, enter "aaaäää" and press "Home" key. -> cursor
pos wrong. (ä is 2 bytes: octal 303, 244)
   then enter any character -> cursor pos more wrong

#include <stdio.h>
#include <readline/readline.h>

main(int argc, char *argv[])
        char const*     line;
        /* \033[1;31m */
        while ((line =
readline("\1\1\033[1;31m\1\2\343\200\216 bla
\343\200\217 bla \343\200\207 ") )) {
                if (line && *line)
                        add_history (line);

        return 0;

Unless you call setlocale() at the beginning of main(), the C
library will not arrange for the correct things to happen.  Even
things like MB_CUR_MAX will not evaluate the way you expect.

``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]