diff options
author | mongo <mongo@iomega> | 2016-08-26 14:02:06 -0300 |
---|---|---|
committer | mongo <mongo@iomega> | 2016-08-26 14:02:06 -0300 |
commit | 2522fcb6fce3285a6e9284a3c019c0dfd0250def (patch) | |
tree | 06ecd5c7b7e120469603b17b6add14dd771c6031 /src/utils/string.c | |
parent | b7a10636b09ac0b8877bca0b849d6cfc1d1ec592 (diff) |
Added count_width_widestring function. it returns the number of wide chars needed to fill p column positions
Diffstat (limited to 'src/utils/string.c')
-rwxr-xr-x | src/utils/string.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils/string.c b/src/utils/string.c index 16eefff..da04d3a 100755 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -335,3 +335,16 @@ int sc_isprint(int d) { return 1; return 0; } + +//return the number of wide chars of +//wchar_t * s string, needed to fill p column positions. +int count_width_widestring(const wchar_t * s, int p) { + int n; + int c_width = 0; + + for (n=0; n<wcslen(s); n++) { + c_width += wcwidth( s[n] ); + if (c_width > p) break; + } + return n; +} |