Bug 86311

Summary: ncurses incorrectly calculates string lengths for multibyte (UTF-8) strings
Product: [Retired] Red Hat Linux Reporter: Alexey Neyman <alex.neyman>
Component: ncursesAssignee: Eido Inoue <havill>
Status: CLOSED NEXTRELEASE QA Contact: Jay Turner <jturner>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: dickey, mitr, srevivo
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-08-07 20:16:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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[]) 
{ 
        initscr(); 
        mvaddnstr(15, 15, argv[1], 10); 
        refresh(); 
        sleep(5); 
        endwin(); 
        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 
LANG=ru_RU.UTF-8)

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.