[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

9. Display width <uniwidth.h>

This include file declares functions that return the display width, measured in columns, of characters or strings, when output to a device that uses non-proportional fonts.

Note that for some rarely used characters the actual fonts or terminal emulators can use a different width. There is no mechanism for communicating the display width of characters across a Unix pseudo-terminal (tty). Also, there are scripts with complex rendering, like the Indic scripts. For these scripts, there is no such concept as non-proportional fonts. Therefore the results of these functions usually work fine on most scripts and on most characters but can fail to represent the actual display width.

These functions are locale dependent. The encoding argument identifies the encoding (e.g. "ISO-8859-2" for Polish).

Function: int uc_width (ucs4_t uc, const char *encoding)

Determines and returns the number of column positions required for uc. Returns -1 if uc is a control character that has an influence on the column position when output.

Function: int u8_width (const uint8_t *s, size_t n, const char *encoding)
Function: int u16_width (const uint16_t *s, size_t n, const char *encoding)
Function: int u32_width (const uint32_t *s, size_t n, const char *encoding)

Determines and returns the number of column positions required for first n units (or fewer if s ends before this) in s. This function ignores control characters in the string.

Function: int u8_strwidth (const uint8_t *s, const char *encoding)
Function: int u16_strwidth (const uint16_t *s, const char *encoding)
Function: int u32_strwidth (const uint32_t *s, const char *encoding)

Determines and returns the number of column positions required for s. This function ignores control characters in the string.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Bruno Haible on February, 24 2024 using texi2html 1.78a.