locale_t newlocale(int category_mask, const char* locale_name, locale_t /*base*/) { // Is 'category_mask' valid? if ((category_mask & ~LC_ALL_MASK) != 0) { errno = EINVAL; return NULL; } if (!__is_supported_locale(locale_name)) { errno = ENOENT; return NULL; } return __new_locale(); }
locale_t newlocale(int category_mask, const char* locale_name, locale_t /*base*/) { // Are 'category_mask' and 'locale_name' valid? if ((category_mask & ~LC_ALL_MASK) != 0 || locale_name == NULL) { errno = EINVAL; return NULL; } if (!__is_supported_locale(locale_name)) { errno = ENOENT; return NULL; } return new __locale_t(strstr(locale_name, "UTF-8") != NULL ? 4 : 1); }
char* setlocale(int category, const char* locale_name) { // Is 'category' valid? if (category < LC_CTYPE || category > LC_IDENTIFICATION) { errno = EINVAL; return NULL; } // Caller wants to set the locale rather than just query? if (locale_name != NULL) { if (!__is_supported_locale(locale_name)) { // We don't support this locale. errno = ENOENT; return NULL; } __bionic_current_locale_is_utf8 = (strstr(locale_name, "UTF-8") != NULL); } return const_cast<char*>(__bionic_current_locale_is_utf8 ? "C.UTF-8" : "C"); }
char* setlocale(int category, char const* locale_name) { // Is 'category' valid? if (category < LC_CTYPE || category > LC_IDENTIFICATION) { errno = EINVAL; return NULL; } // Caller just wants to query the current locale? if (locale_name == NULL) { return const_cast<char*>("C"); } // Caller wants one of the mandatory POSIX locales? if (__is_supported_locale(locale_name)) { return const_cast<char*>("C"); } // We don't support any other locales. errno = ENOENT; return NULL; }