about summary refs log tree commit diff stats
path: root/termbox/utf8.c
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-12-02 23:59:14 -0800
committerKartik Agaram <vc@akkartik.com>2019-12-02 23:59:14 -0800
commitdb66de4a751a6dc170a28bc235d9900e2459e291 (patch)
tree757af80db874df73ce97a1cfdbdbdbb053082981 /termbox/utf8.c
parent41302404c7d2d1d4dbf3858a7bcd5665b43bda82 (diff)
downloadmu-db66de4a751a6dc170a28bc235d9900e2459e291.tar.gz
5788
Diffstat (limited to 'termbox/utf8.c')
-rw-r--r--termbox/utf8.c79
1 files changed, 0 insertions, 79 deletions
diff --git a/termbox/utf8.c b/termbox/utf8.c
deleted file mode 100644
index 26c0c27b..00000000
--- a/termbox/utf8.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "termbox.h"
-
-static const unsigned char utf8_length[256] = {
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-static const unsigned char utf8_mask[6] = {
-  0x7F,
-  0x1F,
-  0x0F,
-  0x07,
-  0x03,
-  0x01
-};
-
-int tb_utf8_char_length(char c)
-{
-  return utf8_length[(unsigned char)c];
-}
-
-int tb_utf8_char_to_unicode(uint32_t *out, const char *c)
-{
-  if (*c == 0)
-    return TB_EOF;
-
-  int i;
-  unsigned char len = tb_utf8_char_length(*c);
-  unsigned char mask = utf8_mask[len-1];
-  uint32_t result = c[0] & mask;
-  for (i = 1; i < len; ++i) {
-    result <<= 6;
-    result |= c[i] & 0x3f;
-  }
-
-  *out = result;
-  return (int)len;
-}
-
-int tb_utf8_unicode_to_char(char *out, uint32_t c)
-{
-  int len = 0;
-  int first;
-  int i;
-
-  if (c < 0x80) {
-    first = 0;
-    len = 1;
-  } else if (c < 0x800) {
-    first = 0xc0;
-    len = 2;
-  } else if (c < 0x10000) {
-    first = 0xe0;
-    len = 3;
-  } else if (c < 0x200000) {
-    first = 0xf0;
-    len = 4;
-  } else if (c < 0x4000000) {
-    first = 0xf8;
-    len = 5;
-  } else {
-    first = 0xfc;
-    len = 6;
-  }
-
-  for (i = len - 1; i > 0; --i) {
-    out[i] = (c & 0x3f) | 0x80;
-    c >>= 6;
-  }
-  out[0] = c | first;
-
-  return len;
-}
kkartik.com> 2015-02-17 16:57:37 -0800 committer Kartik K. Agaram <vc@akkartik.com> 2015-02-17 17:14:45 -0800 775 - starting to reorg C++ mu to use layers' href='/akkartik/mu/commit/cpp/literate/000organization?h=main&id=515309164793b2e03c15954bf8a89f0f288a7f2c'>51530916 ^
455f0338 ^
51530916 ^





be16deb0 ^
b39ceb27 ^
26785f2a ^
b39ceb27 ^


51530916 ^


455f0338 ^






51530916 ^



fb4836dc ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126