How do I configure wcwidth?
Alan Mackenzie
acm@muc.de
Thu Apr 9 13:36:04 GMT 2026
Hello, Libc-help.
I'm trying to enhance the Linux console to handle full UTF8. At the
moment, I'm using the Unifont 8x16 font. It has both half-width glyphs
(e.g. normal ASCII) and full-width glyphs (e.g. Asian languages and many
symbols).
I can currently output these to the console, but the readline system
(used by bash) corrupts some glyphs due to not knowing reliably how wide
they are.
For example, U+2614 (UMBRELLA WITH RAIN DROPS) is a half-width glyph in
Unifont, but readline thinks it is full-width. By contrast, U+2622
(RADIOACTIVE SIGN) is full-width in Unifont, but half-width in readline.
I think readline uses the glibc function wcwidth, the function that
returns the width in column positions of its utf32 argument. I would
like to configure this function for Unifont. I'd appreciate help on
doing this.
I've glanced through some of the glibc source code, in particular
..../glibc-2.42/locale/programs/ld-ctype.c and I think the wcwidth
configuration is part of the locale. Can this be?
If so, the info manual ‘The GNU C Library Reference Manual’ describes
how to select a locale and the effect of this, but doesn't seem to say
how to modify a locale, or create a new one from scratch.
In summary, I'd like to get readline recognising the correct widths for
Unifont glyphs. Am I on the right track?
Thanks!
--
Alan Mackenzie (Nuremberg, Germany).
More information about the Libc-help
mailing list