{"id":4943,"date":"2022-12-20T18:36:59","date_gmt":"2022-12-20T21:36:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/newlocale-man3p\/"},"modified":"2022-12-20T18:36:59","modified_gmt":"2022-12-20T21:36:59","slug":"newlocale-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/newlocale-man3p\/","title":{"rendered":"NEWLOCALE (man3p)"},"content":{"rendered":"<h1 align=\"center\">NEWLOCALE<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">newlocale \u2014 create or modify a locale object<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <locale.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">locale_t newlocale(int <i>category_mask<\/i>, const char *<i>locale<\/i>, <br \/> locale_t <i>base<\/i>);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>newlocale<\/i>() function shall create a new locale object or modify an existing one. If the <i>base<\/i> argument is (<b>locale_t<\/b>)0, a new locale object shall be created. It is unspecified whether the locale object pointed to by <i>base<\/i> shall be modified, or freed and a new locale object created.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>category_mask<\/i> argument specifies the locale categories to be set or modified. Values for <i>category_mask<\/i> shall be constructed by a bitwise-inclusive OR of the symbolic constants <i>LC_CTYPE_MASK<\/i>, <i>LC_NUMERIC_MASK<\/i>, <i>LC_TIME_MASK<\/i>, <i>LC_COLLATE_MASK<\/i>, <i>LC_MONETARY_MASK<\/i>, and <i>LC_MESSAGES_MASK<\/i>, or any of the implementation-defined mask values defined in <i><locale.h><\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For each category with the corresponding bit set in <i>category_mask<\/i> the data from the locale named by <i>locale<\/i> shall be used. In the case of modifying an existing locale object, the data from the locale named by <i>locale<\/i> shall replace the existing data within the locale object. If a completely new locale object is created, the data for all sections not requested by <i>category_mask<\/i> shall be taken from the default locale.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The following preset values of <i>locale<\/i> are defined for all settings of <i>category_mask<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>&#8220;POSIX&#8221;<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"71%\">\n<p>Specifies the minimal environment for C-language translation called the POSIX locale.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>&#8220;C&#8221;<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"71%\">\n<p>Equivalent to <b>&#8220;POSIX&#8221;<\/b>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>&#8220;&#8221;<\/p>\n<\/td>\n<td width=\"7%\"><\/td>\n<td width=\"71%\">\n<p>Specifies an implementation-defined native environment. This corresponds to the value of the associated environment variables, <i>LC_*<\/i> and <i>LANG<\/i>; see the Base Definitions volume of POSIX.1-2017, <i>Chapter 7<\/i>, <i>Locale<\/i> and <i>Chapter 8<\/i>, <i>Environment Variables<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">If the <i>base<\/i> argument is not (<b>locale_t<\/b>)0 and the <i>newlocale<\/i>() function call succeeds, the contents of <i>base<\/i> are unspecified. Applications shall ensure that they stop using <i>base<\/i> as a locale object before calling <i>newlocale<\/i>(). If the function call fails and the <i>base<\/i> argument is not (<b>locale_t<\/b>)0, the contents of <i>base<\/i> shall remain valid and unchanged.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The behavior is undefined if the <i>base<\/i> argument is the special locale object LC_GLOBAL_LOCALE, or is not a valid locale object handle and is not (<b>locale_t<\/b>)0.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Upon successful completion, the <i>newlocale<\/i>() function shall return a handle which the caller may use on subsequent calls to <i>duplocale<\/i>(), <i>freelocale<\/i>(), and other functions taking a <b>locale_t<\/b> argument.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Upon failure, the <i>newlocale<\/i>() function shall return (<b>locale_t<\/b>)0 and set <i>errno<\/i> to indicate the error.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>newlocale<\/i>() function shall fail if:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>ENOMEM<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">There is not enough memory available to create the locale object or load the locale data.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>The <i>category_mask<\/i> contains a bit that does not correspond to a valid category.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENOENT<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>For any of the categories in <i>category_mask<\/i>, the locale data is not available.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>newlocale<\/i>() function may fail if:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"76%\">\n<p style=\"margin-top: 1em\">The <i>locale<\/i> argument is not a valid string pointer.<\/p>\n<\/td>\n<td width=\"2%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><b>Constructing a Locale Object from Different Locales<\/b><\/i> <br \/> The following example shows the construction of a locale where the <i>LC_CTYPE<\/i> category data comes from a locale <i>loc1<\/i> and the <i>LC_TIME<\/i> category data from a locale <i>loc2<\/i>:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <locale.h> <br \/> &#8230; <br \/> locale_t loc, new_loc;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Get the &#8220;loc1&#8221; data. *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">loc = newlocale (LC_CTYPE_MASK, &#8220;loc1&#8221;, (locale_t)0); <br \/> if (loc == (locale_t) 0) <br \/> abort ();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Get the &#8220;loc2&#8221; data. *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">new_loc = newlocale (LC_TIME_MASK, &#8220;loc2&#8221;, loc); <br \/> if (new_loc != (locale_t) 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var We don t abort if this fails. In this case this <br \/> simply used to unchanged locale object. bodies\/ usr\/ <br \/> loc = new_loc;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">&#8230;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Freeing up a Locale Object<\/b> <br \/> The following example shows a code fragment to free a locale object created by <i>newlocale<\/i>():<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <locale.h> <br \/> &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Every locale object allocated with newlocale() should be <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr freed using freelocale(): <br \/> *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">locale_t loc;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Get the locale. *\/<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">loc = newlocale (LC_CTYPE_MASK | LC_TIME_MASK, &#8220;locname&#8221;, (locale_t)0);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* &#8230; Use the locale object &#8230; bodies\/ usr\/ <br \/> &#8230;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\/* Free the locale object resources. bodies\/ usr\/ <br \/> freelocale (loc);<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Handles for locale objects created by the <i>newlocale<\/i>() function should either be released by a corresponding call to <i>freelocale<\/i>(), or be used as a base locale to another <i>newlocale<\/i>() call.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The special locale object LC_GLOBAL_LOCALE must not be passed for the <i>base<\/i> argument, even when returned by the <i>uselocale<\/i>() function.<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>duplocale<\/i>(), <i>freelocale<\/i>(), <i>uselocale<\/i>()<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <i>Chapter 7<\/i>, <i>Locale<\/i>, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>, <b><locale.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  newlocale \u2014 create or modify a locale object <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[1594,1838],"class_list":["post-4943","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-man3p","tag-newlocale"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4943"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4943\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}