mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-12 08:21:02 -04:00
wcwidth: provide our own implementation of wcwidth() and wcswidth()
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
This commit is contained in:
parent
99ebff5a51
commit
c758949145
7 changed files with 7123 additions and 0 deletions
14
my-wcwidth.h
Normal file
14
my-wcwidth.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue