1// NOTE: The following code was generated by "library/core/src/unicode/printable.py",
2// do not edit directly!
3
4fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8], normal: &[u8]) -> bool {
5 let xupper = (x >> 8) as u8;
6 let mut lowerstart = 0;
7 for &(upper, lowercount) in singletonuppers {
8 let lowerend = lowerstart + lowercount as usize;
9 if xupper == upper {
10 for &lower in &singletonlowers[lowerstart..lowerend] {
11 if lower == x as u8 {
12 return false;
13 }
14 }
15 } else if xupper < upper {
16 break;
17 }
18 lowerstart = lowerend;
19 }
20
21 let mut x = x as i32;
22 let mut normal = normal.iter().cloned();
23 let mut current = true;
24 while let Some(v) = normal.next() {
25 let len = if v & 0x80 != 0 {
26 ((v & 0x7f) as i32) << 8 | normal.next().unwrap() as i32
27 } else {
28 v as i32
29 };
30 x -= len;
31 if x < 0 {
32 break;
33 }
34 current = !current;
35 }
36 current
37}
38
39pub(crate) fn is_printable(x: char) -> bool {
40 let x = x as u32;
41 let lower = x as u16;
42
43 if x < 32 {
44 // ASCII fast path
45 false
46 } else if x < 127 {
47 // ASCII fast path
48 true
49 } else if x < 0x10000 {
50 check(lower, SINGLETONS0U, SINGLETONS0L, NORMAL0)
51 } else if x < 0x20000 {
52 check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1)
53 } else {
54 if 0x2a6e0 <= x && x < 0x2a700 {
55 return false;
56 }
57 if 0x2b73a <= x && x < 0x2b740 {
58 return false;
59 }
60 if 0x2b81e <= x && x < 0x2b820 {
61 return false;
62 }
63 if 0x2cea2 <= x && x < 0x2ceb0 {
64 return false;
65 }
66 if 0x2ebe1 <= x && x < 0x2f800 {
67 return false;
68 }
69 if 0x2fa1e <= x && x < 0x30000 {
70 return false;
71 }
72 if 0x3134b <= x && x < 0x31350 {
73 return false;
74 }
75 if 0x323b0 <= x && x < 0xe0100 {
76 return false;
77 }
78 if 0xe01f0 <= x && x < 0x110000 {
79 return false;
80 }
81 true
82 }
83}
84
85#[rustfmt::skip]
86const SINGLETONS0U: &[(u8, u8)] = &[
87 (0x00, 1),
88 (0x03, 5),
89 (0x05, 6),
90 (0x06, 2),
91 (0x07, 6),
92 (0x08, 7),
93 (0x09, 17),
94 (0x0a, 28),
95 (0x0b, 25),
96 (0x0c, 26),
97 (0x0d, 16),
98 (0x0e, 12),
99 (0x0f, 4),
100 (0x10, 3),
101 (0x12, 18),
102 (0x13, 9),
103 (0x16, 1),
104 (0x17, 4),
105 (0x18, 1),
106 (0x19, 3),
107 (0x1a, 7),
108 (0x1b, 1),
109 (0x1c, 2),
110 (0x1f, 22),
111 (0x20, 3),
112 (0x2b, 3),
113 (0x2d, 11),
114 (0x2e, 1),
115 (0x30, 3),
116 (0x31, 2),
117 (0x32, 1),
118 (0xa7, 2),
119 (0xa9, 2),
120 (0xaa, 4),
121 (0xab, 8),
122 (0xfa, 2),
123 (0xfb, 5),
124 (0xfd, 2),
125 (0xfe, 3),
126 (0xff, 9),
127];
128#[rustfmt::skip]
129const SINGLETONS0L: &[u8] = &[
130 0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
131 0x58, 0x8b, 0x8c, 0x90, 0x1c, 0xdd, 0x0e, 0x0f,
132 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f, 0x5c,
133 0x5d, 0x5f, 0xe2, 0x84, 0x8d, 0x8e, 0x91, 0x92,
134 0xa9, 0xb1, 0xba, 0xbb, 0xc5, 0xc6, 0xc9, 0xca,
135 0xde, 0xe4, 0xe5, 0xff, 0x00, 0x04, 0x11, 0x12,
136 0x29, 0x31, 0x34, 0x37, 0x3a, 0x3b, 0x3d, 0x49,
137 0x4a, 0x5d, 0x84, 0x8e, 0x92, 0xa9, 0xb1, 0xb4,
138 0xba, 0xbb, 0xc6, 0xca, 0xce, 0xcf, 0xe4, 0xe5,
139 0x00, 0x04, 0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31,
140 0x34, 0x3a, 0x3b, 0x45, 0x46, 0x49, 0x4a, 0x5e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, 0x10, 0x27, 0x2f,
163 0xee, 0xef, 0x6e, 0x6f, 0x37, 0x3d, 0x3f, 0x42,
164 0x45, 0x90, 0x91, 0x53, 0x67, 0x75, 0xc8, 0xc9,
165 0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
166];
167#[rustfmt::skip]
168const SINGLETONS1U: &[(u8, u8)] = &[
169 (0x00, 6),
170 (0x01, 1),
171 (0x03, 1),
172 (0x04, 2),
173 (0x05, 7),
174 (0x07, 2),
175 (0x08, 8),
176 (0x09, 2),
177 (0x0a, 5),
178 (0x0b, 2),
179 (0x0e, 4),
180 (0x10, 1),
181 (0x11, 2),
182 (0x12, 5),
183 (0x13, 17),
184 (0x14, 1),
185 (0x15, 2),
186 (0x17, 2),
187 (0x19, 13),
188 (0x1c, 5),
189 (0x1d, 8),
190 (0x1f, 1),
191 (0x24, 1),
192 (0x6a, 4),
193 (0x6b, 2),
194 (0xaf, 3),
195 (0xb1, 2),
196 (0xbc, 2),
197 (0xcf, 2),
198 (0xd1, 2),
199 (0xd4, 12),
200 (0xd5, 9),
201 (0xd6, 2),
202 (0xd7, 2),
203 (0xda, 1),
204 (0xe0, 5),
205 (0xe1, 2),
206 (0xe7, 4),
207 (0xe8, 2),
208 (0xee, 32),
209 (0xf0, 4),
210 (0xf8, 2),
211 (0xfa, 3),
212 (0xfb, 1),
213];
214#[rustfmt::skip]
215const SINGLETONS1L: &[u8] = &[
216 0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
217 0x9e, 0x9f, 0x7b, 0x8b, 0x93, 0x96, 0xa2, 0xb2,
218 0xba, 0x86, 0xb1, 0x06, 0x07, 0x09, 0x36, 0x3d,
219 0x3e, 0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18,
220 0x36, 0x37, 0x56, 0x57, 0x7f, 0xaa, 0xae, 0xaf,
221 0xbd, 0x35, 0xe0, 0x12, 0x87, 0x89, 0x8e, 0x9e,
222 0x04, 0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34,
223 0x3a, 0x45, 0x46, 0x49, 0x4a, 0x4e, 0x4f, 0x64,
224 0x65, 0x5c, 0xb6, 0xb7, 0x1b, 0x1c, 0x07, 0x08,
225 0x0a, 0x0b, 0x14, 0x17, 0x36, 0x39, 0x3a, 0xa8,
226 0xa9, 0xd8, 0xd9, 0x09, 0x37, 0x90, 0x91, 0xa8,
227 0x07, 0x0a, 0x3b, 0x3e, 0x66, 0x69, 0x8f, 0x92,
228 0x11, 0x6f, 0x5f, 0xbf, 0xee, 0xef, 0x5a, 0x62,
229 0xf4, 0xfc, 0xff, 0x53, 0x54, 0x9a, 0x9b, 0x2e,
230 0x2f, 0x27, 0x28, 0x55, 0x9d, 0xa0, 0xa1, 0xa3,
231 0xa4, 0xa7, 0xa8, 0xad, 0xba, 0xbc, 0xc4, 0x06,
232 0x0b, 0x0c, 0x15, 0x1d, 0x3a, 0x3f, 0x45, 0x51,
233 0xa6, 0xa7, 0xcc, 0xcd, 0xa0, 0x07, 0x19, 0x1a,
234 0x22, 0x25, 0x3e, 0x3f, 0xe7, 0xec, 0xef, 0xff,
235 0xc5, 0xc6, 0x04, 0x20, 0x23, 0x25, 0x26, 0x28,
236 0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c, 0x50, 0x53,
237 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x63,
238 0x65, 0x66, 0x6b, 0x73, 0x78, 0x7d, 0x7f, 0x8a,
239 0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, 0xae, 0xaf,
240 0x6e, 0x6f, 0xbe, 0x93,
241];
242#[rustfmt::skip]
243const NORMAL0: &[u8] = &[
244 0x00, 0x20,
245 0x5f, 0x22,
246 0x82, 0xdf, 0x04,
247 0x82, 0x44, 0x08,
248 0x1b, 0x04,
249 0x06, 0x11,
250 0x81, 0xac, 0x0e,
251 0x80, 0xab, 0x05,
252 0x1f, 0x09,
253 0x81, 0x1b, 0x03,
254 0x19, 0x08,
255 0x01, 0x04,
256 0x2f, 0x04,
257 0x34, 0x04,
258 0x07, 0x03,
259 0x01, 0x07,
260 0x06, 0x07,
261 0x11, 0x0a,
262 0x50, 0x0f,
263 0x12, 0x07,
264 0x55, 0x07,
265 0x03, 0x04,
266 0x1c, 0x0a,
267 0x09, 0x03,
268 0x08, 0x03,
269 0x07, 0x03,
270 0x02, 0x03,
271 0x03, 0x03,
272 0x0c, 0x04,
273 0x05, 0x03,
274 0x0b, 0x06,
275 0x01, 0x0e,
276 0x15, 0x05,
277 0x4e, 0x07,
278 0x1b, 0x07,
279 0x57, 0x07,
280 0x02, 0x06,
281 0x17, 0x0c,
282 0x50, 0x04,
283 0x43, 0x03,
284 0x2d, 0x03,
285 0x01, 0x04,
286 0x11, 0x06,
287 0x0f, 0x0c,
288 0x3a, 0x04,
289 0x1d, 0x25,
290 0x5f, 0x20,
291 0x6d, 0x04,
292 0x6a, 0x25,
293 0x80, 0xc8, 0x05,
294 0x82, 0xb0, 0x03,
295 0x1a, 0x06,
296 0x82, 0xfd, 0x03,
297 0x59, 0x07,
298 0x16, 0x09,
299 0x18, 0x09,
300 0x14, 0x0c,
301 0x14, 0x0c,
302 0x6a, 0x06,
303 0x0a, 0x06,
304 0x1a, 0x06,
305 0x59, 0x07,
306 0x2b, 0x05,
307 0x46, 0x0a,
308 0x2c, 0x04,
309 0x0c, 0x04,
310 0x01, 0x03,
311 0x31, 0x0b,
312 0x2c, 0x04,
313 0x1a, 0x06,
314 0x0b, 0x03,
315 0x80, 0xac, 0x06,
316 0x0a, 0x06,
317 0x2f, 0x31,
318 0x4d, 0x03,
319 0x80, 0xa4, 0x08,
320 0x3c, 0x03,
321 0x0f, 0x03,
322 0x3c, 0x07,
323 0x38, 0x08,
324 0x2b, 0x05,
325 0x82, 0xff, 0x11,
326 0x18, 0x08,
327 0x2f, 0x11,
328 0x2d, 0x03,
329 0x21, 0x0f,
330 0x21, 0x0f,
331 0x80, 0x8c, 0x04,
332 0x82, 0x97, 0x19,
333 0x0b, 0x15,
334 0x88, 0x94, 0x05,
335 0x2f, 0x05,
336 0x3b, 0x07,
337 0x02, 0x0e,
338 0x18, 0x09,
339 0x80, 0xbe, 0x22,
340 0x74, 0x0c,
341 0x80, 0xd6, 0x1a,
342 0x0c, 0x05,
343 0x80, 0xff, 0x05,
344 0x80, 0xdf, 0x0c,
345 0xf2, 0x9d, 0x03,
346 0x37, 0x09,
347 0x81, 0x5c, 0x14,
348 0x80, 0xb8, 0x08,
349 0x80, 0xcb, 0x05,
350 0x0a, 0x18,
351 0x3b, 0x03,
352 0x0a, 0x06,
353 0x38, 0x08,
354 0x46, 0x08,
355 0x0c, 0x06,
356 0x74, 0x0b,
357 0x1e, 0x03,
358 0x5a, 0x04,
359 0x59, 0x09,
360 0x80, 0x83, 0x18,
361 0x1c, 0x0a,
362 0x16, 0x09,
363 0x4c, 0x04,
364 0x80, 0x8a, 0x06,
365 0xab, 0xa4, 0x0c,
366 0x17, 0x04,
367 0x31, 0xa1, 0x04,
368 0x81, 0xda, 0x26,
369 0x07, 0x0c,
370 0x05, 0x05,
371 0x80, 0xa6, 0x10,
372 0x81, 0xf5, 0x07,
373 0x01, 0x20,
374 0x2a, 0x06,
375 0x4c, 0x04,
376 0x80, 0x8d, 0x04,
377 0x80, 0xbe, 0x03,
378 0x1b, 0x03,
379 0x0f, 0x0d,
380];
381#[rustfmt::skip]
382const NORMAL1: &[u8] = &[
383 0x5e, 0x22,
384 0x7b, 0x05,
385 0x03, 0x04,
386 0x2d, 0x03,
387 0x66, 0x03,
388 0x01, 0x2f,
389 0x2e, 0x80, 0x82,
390 0x1d, 0x03,
391 0x31, 0x0f,
392 0x1c, 0x04,
393 0x24, 0x09,
394 0x1e, 0x05,
395 0x2b, 0x05,
396 0x44, 0x04,
397 0x0e, 0x2a,
398 0x80, 0xaa, 0x06,
399 0x24, 0x04,
400 0x24, 0x04,
401 0x28, 0x08,
402 0x34, 0x0b,
403 0x4e, 0x43,
404 0x81, 0x37, 0x09,
405 0x16, 0x0a,
406 0x08, 0x18,
407 0x3b, 0x45,
408 0x39, 0x03,
409 0x63, 0x08,
410 0x09, 0x30,
411 0x16, 0x05,
412 0x21, 0x03,
413 0x1b, 0x05,
414 0x01, 0x40,
415 0x38, 0x04,
416 0x4b, 0x05,
417 0x2f, 0x04,
418 0x0a, 0x07,
419 0x09, 0x07,
420 0x40, 0x20,
421 0x27, 0x04,
422 0x0c, 0x09,
423 0x36, 0x03,
424 0x3a, 0x05,
425 0x1a, 0x07,
426 0x04, 0x0c,
427 0x07, 0x50,
428 0x49, 0x37,
429 0x33, 0x0d,
430 0x33, 0x07,
431 0x2e, 0x08,
432 0x0a, 0x81, 0x26,
433 0x52, 0x4b,
434 0x2b, 0x08,
435 0x2a, 0x16,
436 0x1a, 0x26,
437 0x1c, 0x14,
438 0x17, 0x09,
439 0x4e, 0x04,
440 0x24, 0x09,
441 0x44, 0x0d,
442 0x19, 0x07,
443 0x0a, 0x06,
444 0x48, 0x08,
445 0x27, 0x09,
446 0x75, 0x0b,
447 0x42, 0x3e,
448 0x2a, 0x06,
449 0x3b, 0x05,
450 0x0a, 0x06,
451 0x51, 0x06,
452 0x01, 0x05,
453 0x10, 0x03,
454 0x05, 0x80, 0x8b,
455 0x62, 0x1e,
456 0x48, 0x08,
457 0x0a, 0x80, 0xa6,
458 0x5e, 0x22,
459 0x45, 0x0b,
460 0x0a, 0x06,
461 0x0d, 0x13,
462 0x3a, 0x06,
463 0x0a, 0x36,
464 0x2c, 0x04,
465 0x17, 0x80, 0xb9,
466 0x3c, 0x64,
467 0x53, 0x0c,
468 0x48, 0x09,
469 0x0a, 0x46,
470 0x45, 0x1b,
471 0x48, 0x08,
472 0x53, 0x0d,
473 0x49, 0x07,
474 0x0a, 0x80, 0xf6,
475 0x46, 0x0a,
476 0x1d, 0x03,
477 0x47, 0x49,
478 0x37, 0x03,
479 0x0e, 0x08,
480 0x0a, 0x06,
481 0x39, 0x07,
482 0x0a, 0x81, 0x36,
483 0x19, 0x07,
484 0x3b, 0x03,
485 0x1c, 0x56,
486 0x01, 0x0f,
487 0x32, 0x0d,
488 0x83, 0x9b, 0x66,
489 0x75, 0x0b,
490 0x80, 0xc4, 0x8a, 0x4c,
491 0x63, 0x0d,
492 0x84, 0x30, 0x10,
493 0x16, 0x8f, 0xaa,
494 0x82, 0x47, 0xa1, 0xb9,
495 0x82, 0x39, 0x07,
496 0x2a, 0x04,
497 0x5c, 0x06,
498 0x26, 0x0a,
499 0x46, 0x0a,
500 0x28, 0x05,
501 0x13, 0x82, 0xb0,
502 0x5b, 0x65,
503 0x4b, 0x04,
504 0x39, 0x07,
505 0x11, 0x40,
506 0x05, 0x0b,
507 0x02, 0x0e,
508 0x97, 0xf8, 0x08,
509 0x84, 0xd6, 0x2a,
510 0x09, 0xa2, 0xe7,
511 0x81, 0x33, 0x0f,
512 0x01, 0x1d,
513 0x06, 0x0e,
514 0x04, 0x08,
515 0x81, 0x8c, 0x89, 0x04,
516 0x6b, 0x05,
517 0x0d, 0x03,
518 0x09, 0x07,
519 0x10, 0x92, 0x60,
520 0x47, 0x09,
521 0x74, 0x3c,
522 0x80, 0xf6, 0x0a,
523 0x73, 0x08,
524 0x70, 0x15,
525 0x46, 0x7a,
526 0x14, 0x0c,
527 0x14, 0x0c,
528 0x57, 0x09,
529 0x19, 0x80, 0x87,
530 0x81, 0x47, 0x03,
531 0x85, 0x42, 0x0f,
532 0x15, 0x84, 0x50,
533 0x1f, 0x06,
534 0x06, 0x80, 0xd5,
535 0x2b, 0x05,
536 0x3e, 0x21,
537 0x01, 0x70,
538 0x2d, 0x03,
539 0x1a, 0x04,
540 0x02, 0x81, 0x40,
541 0x1f, 0x11,
542 0x3a, 0x05,
543 0x01, 0x81, 0xd0,
544 0x2a, 0x82, 0xe6,
545 0x80, 0xf7, 0x29,
546 0x4c, 0x04,
547 0x0a, 0x04,
548 0x02, 0x83, 0x11,
549 0x44, 0x4c,
550 0x3d, 0x80, 0xc2,
551 0x3c, 0x06,
552 0x01, 0x04,
553 0x55, 0x05,
554 0x1b, 0x34,
555 0x02, 0x81, 0x0e,
556 0x2c, 0x04,
557 0x64, 0x0c,
558 0x56, 0x0a,
559 0x80, 0xae, 0x38,
560 0x1d, 0x0d,
561 0x2c, 0x04,
562 0x09, 0x07,
563 0x02, 0x0e,
564 0x06, 0x80, 0x9a,
565 0x83, 0xd8, 0x04,
566 0x11, 0x03,
567 0x0d, 0x03,
568 0x77, 0x04,
569 0x5f, 0x06,
570 0x0c, 0x04,
571 0x01, 0x0f,
572 0x0c, 0x04,
573 0x38, 0x08,
574 0x0a, 0x06,
575 0x28, 0x08,
576 0x22, 0x4e,
577 0x81, 0x54, 0x0c,
578 0x1d, 0x03,
579 0x09, 0x07,
580 0x36, 0x08,
581 0x0e, 0x04,
582 0x09, 0x07,
583 0x09, 0x07,
584 0x80, 0xcb, 0x25,
585 0x0a, 0x84, 0x06,
586];
587