Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/unicode.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/libbb/unicode.c
r2725 r3232 24 24 /* Unicode support using libc locale support. */ 25 25 26 void FAST_FUNC init_unicode(void)26 void FAST_FUNC reinit_unicode(const char *LANG) 27 27 { 28 28 static const char unicode_0x394[] = { 0xce, 0x94, 0 }; 29 29 size_t width; 30 30 31 if (unicode_status != UNICODE_UNKNOWN) 32 return; 31 //TODO: avoid repeated calls by caching last string? 32 setlocale(LC_ALL, (LANG && LANG[0]) ? LANG : "C"); 33 33 34 /* In unicode, this is a one character string */ 34 35 // can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused … … 37 38 } 38 39 40 void FAST_FUNC init_unicode(void) 41 { 42 if (unicode_status == UNICODE_UNKNOWN) 43 reinit_unicode(getenv("LANG")); 44 } 45 39 46 #else 40 47 … … 42 49 43 50 # if ENABLE_FEATURE_CHECK_UNICODE_IN_ENV 44 void FAST_FUNC init_unicode(void) 45 { 46 char *lang; 47 48 if (unicode_status != UNICODE_UNKNOWN) 49 return; 50 51 void FAST_FUNC reinit_unicode(const char *LANG) 52 { 51 53 unicode_status = UNICODE_OFF; 52 lang = getenv("LANG"); 53 if (!lang || !(strstr(lang, ".utf") || strstr(lang, ".UTF"))) 54 if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF"))) 54 55 return; 55 56 unicode_status = UNICODE_ON; 57 } 58 59 void FAST_FUNC init_unicode(void) 60 { 61 if (unicode_status == UNICODE_UNKNOWN) 62 reinit_unicode(getenv("LANG")); 56 63 } 57 64 # endif … … 1108 1115 return unicode_conv_to_printable2(stats, src, INT_MAX, 0); 1109 1116 } 1117 char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width) 1118 { 1119 return unicode_conv_to_printable2(/*stats:*/ NULL, src, width, UNI_FLAG_PAD); 1120 } 1121 1122 #ifdef UNUSED 1110 1123 char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth) 1111 1124 { 1112 1125 return unicode_conv_to_printable2(stats, src, maxwidth, 0); 1113 1126 } 1114 char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width) 1115 { 1116 return unicode_conv_to_printable2(stats, src, width, UNI_FLAG_PAD); 1117 } 1118 1119 #ifdef UNUSED 1127 1120 1128 unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src) 1121 1129 {
Note:
See TracChangeset
for help on using the changeset viewer.