1DUPLOCALE(3P)              POSIX Programmer's Manual             DUPLOCALE(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       duplocale — duplicate a locale object
14

SYNOPSIS

16       #include <locale.h>
17
18       locale_t duplocale(locale_t locobj);
19

DESCRIPTION

21       The duplocale() function shall create a duplicate copy  of  the  locale
22       object referenced by the locobj argument.
23
24       If  the locobj argument is LC_GLOBAL_LOCALE, duplocale() shall create a
25       new locale object containing a copy of the global locale determined  by
26       the setlocale() function.
27
28       The  behavior is undefined if the locobj argument is not a valid locale
29       object handle.
30

RETURN VALUE

32       Upon successful completion, the duplocale()  function  shall  return  a
33       handle  for  a  new  locale object. Otherwise, duplocale() shall return
34       (locale_t)0 and set errno to indicate the error.
35

ERRORS

37       The duplocale() function shall fail if:
38
39       ENOMEM There is not enough memory available to create the locale object
40              or load the locale data.
41
42       The following sections are informative.
43

EXAMPLES

45   Constructing an Altered Version of an Existing Locale Object
46       The  following  example  shows  a  code  fragment  to create a slightly
47       altered version of an existing locale  object.  The  function  takes  a
48       locale  object  and  a locale name and it replaces the LC_TIME category
49       data in the locale object with that from the named locale.
50
51           #include <locale.h>
52           ...
53
54           locale_t
55           with_changed_lc_time (locale_t obj, const char *name)
56           {
57
58               locale_t retval = duplocale (obj);
59               if (retval != (locale_t) 0)
60               {
61                   locale_t changed = newlocale (LC_TIME_MASK, name, retval);
62                   if (changed == (locale_t) 0)
63                       /* An error occurred. Free all allocated resources. */
64                       freelocale (retval);
65                   retval = changed;
66               }
67               return retval; }
68           }
69

APPLICATION USAGE

71       The use of the duplocale() function is recommended for situations where
72       a  locale  object  is being used in multiple places, and it is possible
73       that the lifetime of the locale object might end before  all  uses  are
74       finished.  Another reason to duplicate a locale object is if a slightly
75       modified form is needed.  This can be achieved by a call to newlocale()
76       following the duplocale() call.
77
78       As with the newlocale() function, handles for locale objects created by
79       the duplocale() function should be released by a corresponding call  to
80       freelocale().
81
82       The  duplocale()  function  can also be used in conjunction with uselo‐
83       cale((locale_t)0).  This returns the locale in effect for  the  calling
84       thread,    but   can   have   the   value   LC_GLOBAL_LOCALE.   Passing
85       LC_GLOBAL_LOCALE to functions such as isalnum_l() results in  undefined
86       behavior,  but  applications can convert it into a usable locale object
87       by using duplocale().
88

RATIONALE

90       None.
91

FUTURE DIRECTIONS

93       None.
94

SEE ALSO

96       freelocale(), newlocale(), uselocale()
97
98       The Base Definitions volume of POSIX.1‐2008, <locale.h>
99
101       Portions of this text are reprinted and reproduced in  electronic  form
102       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
103       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
104       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
105       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
106       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
107       event of any discrepancy between this version and the original IEEE and
108       The  Open Group Standard, the original IEEE and The Open Group Standard
109       is the referee document. The original Standard can be  obtained  online
110       at http://www.unix.org/online.html .
111
112       Any  typographical  or  formatting  errors that appear in this page are
113       most likely to have been introduced during the conversion of the source
114       files  to  man page format. To report such errors, see https://www.ker
115       nel.org/doc/man-pages/reporting_bugs.html .
116
117
118
119IEEE/The Open Group                  2013                        DUPLOCALE(3P)
Impressum