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