• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <wctype.h>
2 #ifndef __LITEOS__
3 #ifdef FEATURE_ICU_LOCALE
4 #include <string.h>
5 #include "locale_impl.h"
6 #endif
7 #endif
8 
9 /* Consider all legal codepoints as printable except for:
10  * - C0 and C1 control characters
11  * - U+2028 and U+2029 (line/para break)
12  * - U+FFF9 through U+FFFB (interlinear annotation controls)
13  * The following code is optimized heavily to make hot paths for the
14  * expected printable characters. */
15 
iswprint(wint_t wc)16 int iswprint(wint_t wc)
17 {
18 	if (wc < 0xffU)
19 		return (wc+1 & 0x7f) >= 0x21;
20 	if (wc < 0x2028U || wc-0x202aU < 0xd800-0x202a || wc-0xe000U < 0xfff9-0xe000)
21 		return 1;
22 	if (wc-0xfffcU > 0x10ffff-0xfffc || (wc&0xfffe)==0xfffe)
23 		return 0;
24 	return 1;
25 }
26 
__iswprint_l(wint_t c,locale_t l)27 int __iswprint_l(wint_t c, locale_t l)
28 {
29 #ifndef __LITEOS__
30 #ifdef FEATURE_ICU_LOCALE
31 	if (icu_locale_wctype_enable && l && l->cat[LC_CTYPE]
32 		&& l->cat[LC_CTYPE]->flag == ICU_VALID) {
33 		char* type_name = (char*)(l->cat[LC_CTYPE]->name);
34 		if (!strcmp(type_name, "zh_CN") || !strcmp(type_name, "en_US.UTF-8")) {
35 			return g_icu_opt_func.u_isprint(c);
36 		}
37 	}
38 #endif
39 #endif
40 	return iswprint(c);
41 }
42 
43 weak_alias(__iswprint_l, iswprint_l);
44