Bug 86311 - ncurses incorrectly calculates string lengths for multibyte (UTF-8) strings
ncurses incorrectly calculates string lengths for multibyte (UTF-8) strings
Product: Red Hat Linux
Classification: Retired
Component: ncurses (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Eido Inoue
Jay Turner
Depends On:
  Show dependency treegraph
Reported: 2003-03-19 08:21 EST by Alexey Neyman
Modified: 2015-01-07 19:04 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-08-07 16:16:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Alexey Neyman 2003-03-19 08:21:51 EST
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-17 20:37:33 EDT
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 02:07:54 EDT
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 16:16:07 EDT
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.