Bug 86311 - ncurses incorrectly calculates string lengths for multibyte (UTF-8) strings
Summary: ncurses incorrectly calculates string lengths for multibyte (UTF-8) strings
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: ncurses
Version: 8.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Eido Inoue
QA Contact: Jay Turner
Depends On:
TreeView+ depends on / blocked
Reported: 2003-03-19 13:21 UTC by Alexey Neyman
Modified: 2015-01-08 00:04 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2003-08-07 20:16:07 UTC

Attachments (Terms of Use)

Description Alexey Neyman 2003-03-19 13:21:51 UTC
Description of problem: 
ncurses functions malfunction for UTF-8 locale; e.g. mvaddnstr() macro 
interprets its argument as byte count, not characters. This breaks some 
3rd party applications, e.g. the 'tin' (http://www.tin.org) newsreader. 
Version-Release number of selected component (if applicable): 
Tries with both ncurses-5.2-28 (RedHat Linux 8.0) and ncurses-5.3-4 (RedHat 
Linux 8.1 beta 3). 
How reproducible: 
The sample program is below; compile with gcc -o tst tst.c -lncurses : 
#include <ncurses.h> 
#include <stdio.h> 
int main(int argc, char *argv[]) 
        mvaddnstr(15, 15, argv[1], 10); 
        return 0; 
Try running it with 1st argument containing only ASCII characters, e.g. 
> ./tst ThisIsALongString 
It outputs the 'ThisIsALon' string, just as expected. Then try to pass it 
any string containing multibyte characters and see it truncated to less  
than 10 characters (e.g. to 5 characters for cyrillic strings, with 

Comment 1 Thomas E. Dickey 2003-05-18 00:37:33 UTC
ncurses does what it is designed to.  If you want UTF-8 capability, use the "--enable-widec"
configure option.  Try reading the installation instructions.

Comment 2 Alexey Neyman 2003-05-19 06:07:54 UTC
I know, that's just what I did here locally. However, the prebuilt packages 
distributed by the Red Hat exhibit this misbehavior. 

Comment 3 Eido Inoue 2003-08-07 20:16:07 UTC
Future releases for UTF-8 environments will be linked against ncursesw. As the
current ncurses provides this, this is a bug with packages that link aginst
ncurses (they should be linking against ncursesw if they're working in UTF-8),
so I'm closing this.

Note You need to log in before you can comment on or make changes to this bug.