mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
This commit adds a new script, generate-wcwidth.py, that generates wcwidth tables from the bundled files (Unicode 14.0): * DerivedGeneralCategory.txt * EastAsianWidth.txt This commit also adds the functions my_wcwidth() and my_wcswidth() that replaces the system’s wcwidth()+wcswidth(), and uses the generated tables to map Unicode codepoints to widths. This is inspired by both XTerm’s wcwidth implementation, as well as https://github.com/jquast/wcwidth. Both of those are based on/inspired by https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
14 lines
302 B
C
14 lines
302 B
C
#pragma once
|
|
#include <wchar.h>
|
|
|
|
#if FOOT_SYSTEM_WCWIDTH == 0
|
|
|
|
int my_wcwidth(wchar_t wc);
|
|
int my_wcswidth(const wchar_t *s, size_t n);
|
|
|
|
#else
|
|
|
|
static inline int my_wcwidth(wchar_t wc) { return wcwidth(wc); }
|
|
static inline int my_wcswidth(const wchar_t *s, size_t n) { return wcswidth(s, n); }
|
|
|
|
#endif
|