@xort/rcmg 0.0.0-stage → 0.1.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/LICENSE-APACHE +176 -0
  2. package/LICENSE-MIT +21 -0
  3. package/PROVENANCE.json +1601 -0
  4. package/README.md +152 -2
  5. package/licenses/registry/allocator-api2-0.2.22-c19b7c6f923b/LICENSE-APACHE +176 -0
  6. package/licenses/registry/allocator-api2-0.2.22-c19b7c6f923b/LICENSE-MIT +23 -0
  7. package/licenses/registry/autocfg-1.5.1-c19b7c6f923b/LICENSE-APACHE +201 -0
  8. package/licenses/registry/autocfg-1.5.1-c19b7c6f923b/LICENSE-MIT +25 -0
  9. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/LICENSE-APACHE +201 -0
  10. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/LICENSE-MIT +25 -0
  11. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/alloc.rs +794 -0
  12. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/mod.rs +93 -0
  13. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/raw_vec.rs +781 -0
  14. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/str/lossy.rs +209 -0
  15. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/str/mod.rs +43 -0
  16. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/string.rs +2191 -0
  17. package/licenses/registry/bumpalo-3.20.4-c19b7c6f923b/src/collections/vec.rs +3051 -0
  18. package/licenses/registry/cfg-if-1.0.5-c19b7c6f923b/LICENSE-APACHE +201 -0
  19. package/licenses/registry/cfg-if-1.0.5-c19b7c6f923b/LICENSE-MIT +25 -0
  20. package/licenses/registry/equivalent-1.0.3-c19b7c6f923b/LICENSE-APACHE +201 -0
  21. package/licenses/registry/equivalent-1.0.3-c19b7c6f923b/LICENSE-MIT +25 -0
  22. package/licenses/registry/foldhash-0.2.0-c19b7c6f923b/LICENSE +19 -0
  23. package/licenses/registry/hashbrown-0.16.1-c19b7c6f923b/LICENSE-APACHE +201 -0
  24. package/licenses/registry/hashbrown-0.16.1-c19b7c6f923b/LICENSE-MIT +25 -0
  25. package/licenses/registry/libm-0.2.16-c19b7c6f923b/LICENSE.txt +258 -0
  26. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/acos.rs +112 -0
  27. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/acosf.rs +79 -0
  28. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/asin.rs +115 -0
  29. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/asinf.rs +68 -0
  30. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/atan.rs +180 -0
  31. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/atan2.rs +131 -0
  32. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/atan2f.rs +90 -0
  33. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/atanf.rs +108 -0
  34. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/cbrt.rs +219 -0
  35. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/cbrtf.rs +73 -0
  36. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/cos.rs +77 -0
  37. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/cosf.rs +86 -0
  38. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/erf.rs +314 -0
  39. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/erff.rs +226 -0
  40. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/exp.rs +156 -0
  41. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/exp2.rs +400 -0
  42. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/exp2f.rs +141 -0
  43. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/expf.rs +103 -0
  44. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/expm1.rs +142 -0
  45. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/expm1f.rs +134 -0
  46. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/fma.rs +171 -0
  47. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/ceil.rs +174 -0
  48. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/floor.rs +157 -0
  49. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fma.rs +278 -0
  50. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fmax.rs +23 -0
  51. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fmaximum.rs +27 -0
  52. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fmaximum_num.rs +29 -0
  53. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fmin.rs +23 -0
  54. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fminimum.rs +27 -0
  55. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fminimum_num.rs +29 -0
  56. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/fmod.rs +116 -0
  57. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/rint.rs +130 -0
  58. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/sqrt.rs +541 -0
  59. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/generic/trunc.rs +148 -0
  60. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/j0.rs +426 -0
  61. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/j0f.rs +363 -0
  62. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/j1.rs +418 -0
  63. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/j1f.rs +383 -0
  64. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/jn.rs +339 -0
  65. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/jnf.rs +253 -0
  66. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_cos.rs +62 -0
  67. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_cosf.rs +29 -0
  68. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_sin.rs +57 -0
  69. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_sinf.rs +30 -0
  70. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_tan.rs +105 -0
  71. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/k_tanf.rs +46 -0
  72. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/lgamma_r.rs +321 -0
  73. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/lgammaf_r.rs +256 -0
  74. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log.rs +118 -0
  75. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log10.rs +116 -0
  76. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log10f.rs +90 -0
  77. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log1p.rs +142 -0
  78. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log1pf.rs +97 -0
  79. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log2.rs +105 -0
  80. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/log2f.rs +86 -0
  81. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/logf.rs +66 -0
  82. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/pow.rs +624 -0
  83. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/powf.rs +343 -0
  84. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/rem_pio2.rs +235 -0
  85. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/rem_pio2_large.rs +476 -0
  86. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/rem_pio2f.rs +65 -0
  87. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/sin.rs +95 -0
  88. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/sincos.rs +137 -0
  89. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/sincosf.rs +176 -0
  90. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/sinf.rs +96 -0
  91. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/support/int_traits/narrowing_div.rs +175 -0
  92. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/support/modular.rs +304 -0
  93. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/tan.rs +74 -0
  94. package/licenses/registry/libm-0.2.16-c19b7c6f923b/src/math/tanf.rs +81 -0
  95. package/licenses/registry/num-traits-0.2.19-c19b7c6f923b/LICENSE-APACHE +201 -0
  96. package/licenses/registry/num-traits-0.2.19-c19b7c6f923b/LICENSE-MIT +25 -0
  97. package/licenses/registry/num-traits-0.2.19-c19b7c6f923b/src/lib.rs +635 -0
  98. package/licenses/registry/once_cell-1.21.4-c19b7c6f923b/LICENSE-APACHE +201 -0
  99. package/licenses/registry/once_cell-1.21.4-c19b7c6f923b/LICENSE-MIT +23 -0
  100. package/licenses/registry/proc-macro2-1.0.107-c19b7c6f923b/LICENSE-APACHE +176 -0
  101. package/licenses/registry/proc-macro2-1.0.107-c19b7c6f923b/LICENSE-MIT +23 -0
  102. package/licenses/registry/quote-1.0.47-c19b7c6f923b/LICENSE-APACHE +176 -0
  103. package/licenses/registry/quote-1.0.47-c19b7c6f923b/LICENSE-MIT +23 -0
  104. package/licenses/registry/robust-1.2.0-c19b7c6f923b/LICENSE-APACHE +201 -0
  105. package/licenses/registry/robust-1.2.0-c19b7c6f923b/LICENSE-MIT +26 -0
  106. package/licenses/registry/robust-1.2.0-c19b7c6f923b/src/lib.rs +2224 -0
  107. package/licenses/registry/rustversion-1.0.23-c19b7c6f923b/LICENSE-APACHE +176 -0
  108. package/licenses/registry/rustversion-1.0.23-c19b7c6f923b/LICENSE-MIT +23 -0
  109. package/licenses/registry/smallvec-1.16.6-c19b7c6f923b/LICENSE-APACHE +201 -0
  110. package/licenses/registry/smallvec-1.16.6-c19b7c6f923b/LICENSE-MIT +25 -0
  111. package/licenses/registry/spade-2.15.1-c19b7c6f923b/LICENSE-APACHE +202 -0
  112. package/licenses/registry/spade-2.15.1-c19b7c6f923b/LICENSE-MIT +25 -0
  113. package/licenses/registry/syn-2.0.119-c19b7c6f923b/LICENSE-APACHE +176 -0
  114. package/licenses/registry/syn-2.0.119-c19b7c6f923b/LICENSE-MIT +23 -0
  115. package/licenses/registry/unicode-ident-1.0.27-c19b7c6f923b/LICENSE-APACHE +176 -0
  116. package/licenses/registry/unicode-ident-1.0.27-c19b7c6f923b/LICENSE-MIT +23 -0
  117. package/licenses/registry/unicode-ident-1.0.27-c19b7c6f923b/LICENSE-UNICODE +39 -0
  118. package/licenses/registry/wasm-bindgen-0.2.118-c19b7c6f923b/LICENSE-APACHE +201 -0
  119. package/licenses/registry/wasm-bindgen-0.2.118-c19b7c6f923b/LICENSE-MIT +25 -0
  120. package/licenses/registry/wasm-bindgen-macro-0.2.118-c19b7c6f923b/LICENSE-APACHE +201 -0
  121. package/licenses/registry/wasm-bindgen-macro-0.2.118-c19b7c6f923b/LICENSE-MIT +25 -0
  122. package/licenses/registry/wasm-bindgen-macro-support-0.2.118-c19b7c6f923b/LICENSE-APACHE +201 -0
  123. package/licenses/registry/wasm-bindgen-macro-support-0.2.118-c19b7c6f923b/LICENSE-MIT +25 -0
  124. package/licenses/registry/wasm-bindgen-shared-0.2.118-c19b7c6f923b/LICENSE-APACHE +201 -0
  125. package/licenses/registry/wasm-bindgen-shared-0.2.118-c19b7c6f923b/LICENSE-MIT +25 -0
  126. package/licenses/registry-licenses.json +1413 -0
  127. package/licenses/source/LICENSE-APACHE +176 -0
  128. package/licenses/source/LICENSE-MIT +21 -0
  129. package/licenses/source/crates/rcmg-mesh/src/isosurface/LICENSE-PyMCubes +27 -0
  130. package/licenses/source/crates/rcmg-mesh/src/isosurface/NOTICE.md +11 -0
  131. package/licenses/source/vendor/cadcraft-dxf/LICENSE-APACHE +177 -0
  132. package/licenses/source/vendor/cadcraft-dxf/LICENSE-MIT +21 -0
  133. package/node/index.mjs +2 -0
  134. package/node/package.json +3 -0
  135. package/node/rcmg_ffi.d.ts +51 -0
  136. package/node/rcmg_ffi.js +269 -0
  137. package/node/rcmg_ffi_bg.wasm +0 -0
  138. package/node/rcmg_ffi_bg.wasm.d.ts +32 -0
  139. package/package.json +57 -6
  140. package/web/rcmg_ffi.d.ts +108 -0
  141. package/web/rcmg_ffi.js +358 -0
  142. package/web/rcmg_ffi_bg.wasm +0 -0
  143. package/web/rcmg_ffi_bg.wasm.d.ts +32 -0
@@ -0,0 +1,209 @@
1
+ // Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ use crate::collections::str as core_str;
12
+ use core::char;
13
+ use core::fmt;
14
+ use core::fmt::Write;
15
+ use core::str;
16
+
17
+ /// Lossy UTF-8 string.
18
+ pub struct Utf8Lossy<'a> {
19
+ bytes: &'a [u8],
20
+ }
21
+
22
+ impl<'a> Utf8Lossy<'a> {
23
+ pub fn from_bytes(bytes: &'a [u8]) -> Utf8Lossy<'a> {
24
+ Utf8Lossy { bytes }
25
+ }
26
+
27
+ pub fn chunks(&self) -> Utf8LossyChunksIter<'a> {
28
+ Utf8LossyChunksIter {
29
+ source: &self.bytes,
30
+ }
31
+ }
32
+ }
33
+
34
+ /// Iterator over lossy UTF-8 string
35
+ #[allow(missing_debug_implementations)]
36
+ pub struct Utf8LossyChunksIter<'a> {
37
+ source: &'a [u8],
38
+ }
39
+
40
+ #[derive(PartialEq, Eq, Debug)]
41
+ pub struct Utf8LossyChunk<'a> {
42
+ /// Sequence of valid chars.
43
+ /// Can be empty between broken UTF-8 chars.
44
+ pub valid: &'a str,
45
+ /// Single broken char, empty if none.
46
+ /// Empty iff iterator item is last.
47
+ pub broken: &'a [u8],
48
+ }
49
+
50
+ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
51
+ type Item = Utf8LossyChunk<'a>;
52
+
53
+ fn next(&mut self) -> Option<Utf8LossyChunk<'a>> {
54
+ if self.source.is_empty() {
55
+ return None;
56
+ }
57
+
58
+ const TAG_CONT_U8: u8 = 128;
59
+ fn unsafe_get(xs: &[u8], i: usize) -> u8 {
60
+ unsafe { *xs.get_unchecked(i) }
61
+ }
62
+ fn safe_get(xs: &[u8], i: usize) -> u8 {
63
+ if i >= xs.len() {
64
+ 0
65
+ } else {
66
+ unsafe_get(xs, i)
67
+ }
68
+ }
69
+
70
+ let mut i = 0;
71
+ while i < self.source.len() {
72
+ let i_ = i;
73
+
74
+ let byte = unsafe_get(self.source, i);
75
+ i += 1;
76
+
77
+ if byte < 128 {
78
+ } else {
79
+ let w = core_str::utf8_char_width(byte);
80
+
81
+ macro_rules! error {
82
+ () => {{
83
+ unsafe {
84
+ let r = Utf8LossyChunk {
85
+ valid: str::from_utf8_unchecked(&self.source[0..i_]),
86
+ broken: &self.source[i_..i],
87
+ };
88
+ self.source = &self.source[i..];
89
+ return Some(r);
90
+ }
91
+ }};
92
+ }
93
+
94
+ match w {
95
+ 2 => {
96
+ if safe_get(self.source, i) & 192 != TAG_CONT_U8 {
97
+ error!();
98
+ }
99
+ i += 1;
100
+ }
101
+ 3 => {
102
+ match (byte, safe_get(self.source, i)) {
103
+ (0xE0, 0xA0..=0xBF) => (),
104
+ (0xE1..=0xEC, 0x80..=0xBF) => (),
105
+ (0xED, 0x80..=0x9F) => (),
106
+ (0xEE..=0xEF, 0x80..=0xBF) => (),
107
+ _ => {
108
+ error!();
109
+ }
110
+ }
111
+ i += 1;
112
+ if safe_get(self.source, i) & 192 != TAG_CONT_U8 {
113
+ error!();
114
+ }
115
+ i += 1;
116
+ }
117
+ 4 => {
118
+ match (byte, safe_get(self.source, i)) {
119
+ (0xF0, 0x90..=0xBF) => (),
120
+ (0xF1..=0xF3, 0x80..=0xBF) => (),
121
+ (0xF4, 0x80..=0x8F) => (),
122
+ _ => {
123
+ error!();
124
+ }
125
+ }
126
+ i += 1;
127
+ if safe_get(self.source, i) & 192 != TAG_CONT_U8 {
128
+ error!();
129
+ }
130
+ i += 1;
131
+ if safe_get(self.source, i) & 192 != TAG_CONT_U8 {
132
+ error!();
133
+ }
134
+ i += 1;
135
+ }
136
+ _ => {
137
+ error!();
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ let r = Utf8LossyChunk {
144
+ valid: unsafe { str::from_utf8_unchecked(self.source) },
145
+ broken: &[],
146
+ };
147
+ self.source = &[];
148
+ Some(r)
149
+ }
150
+ }
151
+
152
+ impl<'a> fmt::Display for Utf8Lossy<'a> {
153
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
154
+ // If we're the empty string then our iterator won't actually yield
155
+ // anything, so perform the formatting manually
156
+ if self.bytes.is_empty() {
157
+ return "".fmt(f);
158
+ }
159
+
160
+ for Utf8LossyChunk { valid, broken } in self.chunks() {
161
+ // If we successfully decoded the whole chunk as a valid string then
162
+ // we can return a direct formatting of the string which will also
163
+ // respect various formatting flags if possible.
164
+ if valid.len() == self.bytes.len() {
165
+ assert!(broken.is_empty());
166
+ return valid.fmt(f);
167
+ }
168
+
169
+ f.write_str(valid)?;
170
+ if !broken.is_empty() {
171
+ f.write_char(char::REPLACEMENT_CHARACTER)?;
172
+ }
173
+ }
174
+ Ok(())
175
+ }
176
+ }
177
+
178
+ impl<'a> fmt::Debug for Utf8Lossy<'a> {
179
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
180
+ f.write_char('"')?;
181
+
182
+ for Utf8LossyChunk { valid, broken } in self.chunks() {
183
+ // Valid part.
184
+ // Here we partially parse UTF-8 again which is suboptimal.
185
+ {
186
+ let mut from = 0;
187
+ for (i, c) in valid.char_indices() {
188
+ let esc = c.escape_debug();
189
+ // If char needs escaping, flush backlog so far and write, else skip
190
+ if esc.len() != 1 {
191
+ f.write_str(&valid[from..i])?;
192
+ for c in esc {
193
+ f.write_char(c)?;
194
+ }
195
+ from = i + c.len_utf8();
196
+ }
197
+ }
198
+ f.write_str(&valid[from..])?;
199
+ }
200
+
201
+ // Broken parts of string as hex escape.
202
+ for &b in broken {
203
+ write!(f, "\\x{:02x}", b)?;
204
+ }
205
+ }
206
+
207
+ f.write_char('"')
208
+ }
209
+ }
@@ -0,0 +1,43 @@
1
+ // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ //! String manipulation
12
+ //!
13
+ //! For more details, see std::str
14
+
15
+ #[allow(missing_docs)]
16
+ pub mod lossy;
17
+
18
+ // https://tools.ietf.org/html/rfc3629
19
+ #[rustfmt::skip]
20
+ static UTF8_CHAR_WIDTH: [u8; 256] = [
21
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
22
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
23
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
24
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x3F
25
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
26
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x5F
27
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
28
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x7F
29
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
30
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9F
31
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
32
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBF
33
+ 0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
34
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDF
35
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEF
36
+ 4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0, // 0xFF
37
+ ];
38
+
39
+ /// Given a first byte, determines how many bytes are in this UTF-8 character.
40
+ #[inline]
41
+ pub fn utf8_char_width(b: u8) -> usize {
42
+ UTF8_CHAR_WIDTH[b as usize] as usize
43
+ }