This is an updated implementation of Markus Kuhn's wcwidth() function, designed to accurately compute the display width of wide characters.
Unlike the standard wcwidth() function from wchar.h, which depends heavily on system locales:
The behavior of wcwidth() depends on the LC_CTYPE category of the current locale.
This implementation uses Unicode 16.0 derived tables. These tables are generated by a Python script. The goal is to provide a locale-independent, reliable way to determine the display width of a character or string — mainly for my tabular.
While this implementation may not be entirely free from locale influence in all environments, it significantly reduces the complexity and uncertainty associated with locale handling.
This project includes code originally written by Markus Kuhn and is distributed under the following terms:
Markus Kuhn -- 2007-05-26 (Unicode 5.0)
Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted. The author disclaims all warranties with regard to this software.