Unleashed v1.4
[unleashed.git] / share / man / man3c / strxfrm.3c
blob1e2012f5da35b72d0fb44e190ba1ef8c2ebe9534
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T.
44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
46 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
47 .\"
48 .TH STRXFRM 3C "Jun 21, 2014"
49 .SH NAME
50 strxfrm, strxfrm_l \- string transformation
51 .SH SYNOPSIS
52 .LP
53 .nf
54 #include <string.h>
56 \fBsize_t\fR \fBstrxfrm\fR(\fBchar *restrict\fR \fIs1\fR, \fBconst char *restrict\fR \fIs2\fR, \fBsize_t\fR \fIn\fR);
57 .fi
58 .LP
59 .nf
60 \fBsize_t\fR \fBstrxfrm_l\fR(\fBchar *restrict\fR \fIs1\fR, \fBconst char *restrict\fR \fIs2\fR, \fBsize_t\fR \fIn\fR,
61     \fBlocale_t\fR \fIloc\fR);
62 .fi
63 .SH DESCRIPTION
64 .LP
65 The \fBstrxfrm()\fR function transforms the string pointed to by \fIs2\fR and
66 places the resulting string into the array pointed to by \fIs1\fR. The
67 transformation is such that if \fBstrcmp\fR(3C) is applied to two transformed
68 strings, it returns a value greater than, equal to or less than \fB0\fR,
69 corresponding to the result of \fBstrcoll\fR(3C) applied to the same two
70 original strings. No more than \fIn\fR bytes are placed into the resulting
71 array pointed to by \fIs1\fR, including the terminating null byte.  If \fIn\fR
72 is \fB0\fR, \fIs1\fR is permitted to be a null pointer. If copying takes place
73 between objects that overlap, the behavior is undefined.
74 .LP
75 The \fBstrxfrm()\fR function does not change the setting of \fBerrno\fR if
76 successful.
77 .LP
78 Since no return value is reserved to indicate an error, an application wishing
79 to check for error situations should set \fBerrno\fR to 0, then call
80 \fBstrxfrm()\fR, then check \fBerrno\fR.
81 .LP
82 The \fBstrxfrm_l()\fR functions behaves identically to the function
83 \fBstrxfrm()\fR, except instead of operating in the current locale it
84 operates in the locale specified by the argument \fIloc\fR.
85 .SH RETURN VALUES
86 .LP
87 Upon successful completion, \fBstrxfrm()\fR returns the length of the
88 transformed string (not including the terminating null byte). If the value
89 returned is \fIn\fR or more, the contents of the array pointed to by \fIs1\fR
90 are indeterminate.
91 .LP
92 On error, \fBstrxfrm()\fR may set \fBerrno\fR but no return value is reserved
93 to indicate the error.
94 .SH USAGE
95 .LP
96 The transformation function is such that two transformed strings can be ordered
97 by \fBstrcmp\fR(3C) as appropriate to collating sequence information in the
98 locale (category \fBLC_COLLATE\fR).
99 .LP
100 The fact that when \fIn\fR is \fB0\fR, \fIs1\fR is permitted to be a null
101 pointer, is useful to determine the size of the \fIs1\fR array prior to making
102 the transformation.
103 .SH EXAMPLES
105 \fBExample 1 \fRA sample of using the \fBstrxfm()\fR function.
107 The value of the following expression is the size of the array needed to hold
108 the transformation of the string pointed to by \fIs\fR.
111 .in +2
113 1 + strxfrm(NULL, s, 0);
115 .in -2
117 .SH FILES
118 .IP \fB/usr/lib/locale/\fR\fIlocale\fR\fB/LC_COLLATE/*
119 collation database for \fIlocale\fR
120 .SH ATTRIBUTES
122 See \fBattributes\fR(5) for descriptions of the following attributes:
124 box;
125 c | c
126 l | l .
127 ATTRIBUTE TYPE  ATTRIBUTE VALUE
129 CSI     Enabled
131 Interface Stability     Standard
133 MT-Level        MT-Safe
136 .SH SEE ALSO
138 \fBlocaledef\fR(1), \fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBstrcmp\fR(3C),
139 \fBstrcoll\fR(3C), \fBuselocale\fR(3C),
140 \fBwscoll\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)