Commit | Line | Data |
---|---|---|
8d138742 CE |
1 | #include "unicode_config.h" |
2 | #include "unicode.h" | |
3 | ||
4 | #include "eastasianwidth.h" | |
5 | ||
6 | #include <stdlib.h> | |
7 | ||
8 | int unicode_wcwidth(unicode_char c) | |
9 | { | |
10 | size_t b=0; | |
11 | size_t e=sizeof(unicode_wcwidth_tab)/sizeof(unicode_wcwidth_tab[0]); | |
12 | ||
13 | while (b < e) | |
14 | { | |
15 | size_t n=b + (e-b)/2; | |
16 | ||
17 | if (c >= unicode_wcwidth_tab[n][0]) | |
18 | { | |
19 | if (c <= unicode_wcwidth_tab[n][1]) | |
20 | return 2; | |
21 | b=n+1; | |
22 | } | |
23 | else | |
24 | { | |
25 | e=n; | |
26 | } | |
27 | } | |
28 | return 1; | |
29 | } |