iswprint.c 675 B

1234567891011121314151617181920212223242526
  1. #include <wctype.h>
  2. /* Consider all legal codepoints as printable except for:
  3. * - C0 and C1 control characters
  4. * - U+2028 and U+2029 (line/para break)
  5. * - U+FFF9 through U+FFFB (interlinear annotation controls)
  6. * The following code is optimized heavily to make hot paths for the
  7. * expected printable characters. */
  8. int iswprint(wint_t wc)
  9. {
  10. if (wc < 0xffU)
  11. return (wc+1 & 0x7f) >= 0x21;
  12. if (wc < 0x2028U || wc-0x202aU < 0xd800-0x202a || wc-0xe000U < 0xfff9-0xe000)
  13. return 1;
  14. if (wc-0xfffcU > 0x10ffff-0xfffc || (wc&0xfffe)==0xfffe)
  15. return 0;
  16. return 1;
  17. }
  18. int __iswprint_l(wint_t c, locale_t l)
  19. {
  20. return iswprint(c);
  21. }
  22. weak_alias(__iswprint_l, iswprint_l);