Print this page
Garrett's man page edits.

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3c/mbrtowc.3c
          +++ new/usr/src/man/man3c/mbrtowc.3c
   1    1  '\" te
        2 +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
   2    3  .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.  Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
   3    4  .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   4    5  .\" http://www.opengroup.org/bookstore/.
   5    6  .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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.
   6    7  .\"  This notice shall appear on any product containing this material.
   7    8  .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   8    9  .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   9   10  .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  10      -.TH MBRTOWC 3C "Nov 1, 2003"
       11 +.TH MBRTOWC 3C "Jun 23, 2014"
  11   12  .SH NAME
  12      -mbrtowc \- convert a character to a wide-character code (restartable)
       13 +mbrtowc, mbrtowc_l \- convert a character to a wide-character code (restartable)
  13   14  .SH SYNOPSIS
  14   15  .LP
  15   16  .nf
  16   17  #include <wchar.h>
  17   18  
  18   19  \fBsize_t\fR \fBmbrtowc\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
  19   20       \fBmbstate_t *restrict\fR \fIps\fR);
  20   21  .fi
       22 +.LP
       23 +.nf
       24 +#include <wchar.h>
       25 +#include <xlocale.h>
  21   26  
       27 +\fBsize_t\fR \fBmbrtowc_l\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
       28 +     \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
       29 +.fi
  22   30  .SH DESCRIPTION
  23      -.sp
  24   31  .LP
  25      -If \fIs\fR is a null pointer, the \fBmbrtowc()\fR function is equivalent to the
  26      -call:
       32 +If
       33 +.I s
       34 +is a null pointer, the
       35 +.B mbrtowc()
       36 +function is equivalent to the call:
  27   37  .sp
  28   38  .in +2
  29   39  .nf
  30      -mbrtowc(NULL, ``'', 1, ps)
       40 +\fBmbrtowc\fR(NULL, "", 1, \fIps\fR)
  31   41  .fi
  32   42  .in -2
  33      -
  34      -.sp
  35   43  .LP
  36      -In this case, the values of the arguments \fIpwc\fR and \fIn\fR are ignored.
       44 +Likewise, if
       45 +.I s
       46 +is a null pointer, the
       47 +.B mbrtowc_l()
       48 +function is equivalent to the call:
  37   49  .sp
       50 +.in +2
       51 +.nf
       52 +\fBmbrtowc_l\fR(NULL, "", 1, \fIps\fR, \fIloc\fR);
       53 +.fi
       54 +.in -2
  38   55  .LP
  39      -If \fIs\fR is not a null pointer, the \fBmbrtowc()\fR function inspects at most
  40      -\fIn\fR bytes beginning at the byte pointed to by  \fIs\fR to determine the
  41      -number of bytes needed to complete the next  character (including any shift
  42      -sequences).  If the function determines that the next character is completed,
  43      -it determines the value of the corresponding wide-character and then, if
  44      -\fIpwc\fR is not a null pointer, stores that value in the object pointed to by
  45      -\fIpwc\fR. If the corresponding wide-character is the null wide-character, the
       56 +In these cases, the values of the arguments
       57 +.I pwc
       58 +and
       59 +.I n
       60 +are ignored.
       61 +.LP
       62 +If
       63 +.I s
       64 +is not a null pointer, these functions inspect at most
       65 +.I n
       66 +bytes beginning at the byte pointed to by
       67 +.I s
       68 +to determine the number of bytes needed to complete the next character
       69 +(including any shift sequences).  If the functions determine that the next
       70 +character is completed,
       71 +they determine the value of the corresponding wide-character and then, if
       72 +.I pwc
       73 +is not a null pointer, stores that value in the object pointed to by
       74 +.IR pwc .
       75 +If the corresponding wide-character is the null wide-character, the
  46   76  resulting state described is the initial conversion state.
  47      -.sp
  48   77  .LP
  49      -If \fIps\fR is a null pointer, the \fBmbrtowc()\fR function uses its own
  50      -internal \fBmbstate_t\fR object, which is initialized at program startup to the
  51      -initial conversion state.   Otherwise, the  \fBmbstate_t\fR object pointed to
  52      -by \fIps\fR is used to completely describe the current conversion state of the
  53      -associated character sequence. Solaris will behave as if no function defined in
  54      -the Solaris Reference Manual calls \fBmbrtowc()\fR.
  55      -.sp
       78 +If
       79 +.I ps
       80 +is a null pointer, these functions use their own
       81 +internal
       82 +.B mbstate_t
       83 +object, which is initialized at program startup to the
       84 +initial conversion state. Otherwise, the 
       85 +.B mbstate_t
       86 +object pointed to by
       87 +.I ps
       88 +is used to completely describe the current conversion state of the
       89 +associated character sequence. The system will behave as if no function defined
       90 +in the Reference Manual calls
       91 +.B mbrtowc()
       92 +or
       93 +.BR Bmbrtowc_l() .
  56   94  .LP
  57      -The behavior of this function is affected by the \fBLC_CTYPE\fR category of the
  58      -current locale.  See \fBenviron\fR(5).
       95 +The behavior of
       96 +.B mbrtowc()
       97 +is affected by the
       98 +.B LC_CTYPE
       99 +category of the current locale.  The
      100 +.B mbrtowc_l()
      101 +function is affected by the
      102 +.B LC_CTYPE
      103 +category of the specified
      104 +.I loc
      105 +locale object.  See
      106 +.B environ (5).
  59  107  .SH RETURN VALUES
  60      -.sp
  61  108  .LP
  62      -The \fBmbrtowc()\fR function returns the first of the following that applies:
  63      -.sp
  64      -.ne 2
  65      -.na
  66      -\fB\fB0\fR\fR
  67      -.ad
  68      -.RS 17n
  69      -If the next \fIn\fR or fewer bytes complete the character that corresponds to
      109 +The
      110 +.B mbrtowc()
      111 +and
      112 +.B mbrtowc_l()
      113 +functions return the first of the following that applies:
      114 +.IP \fB0\fR
      115 +If the next
      116 +.I n
      117 +or fewer bytes complete the character that corresponds to
  70  118  the null wide-character (which is the value stored).
  71      -.RE
  72      -
  73      -.sp
  74      -.ne 2
  75      -.na
  76      -\fB\fBpositive\fR\fR
  77      -.ad
  78      -.RS 17n
  79      -If the next \fIn\fR or fewer bytes complete a valid character (which is the
      119 +.IP \fBpositive\fR
      120 +If the next
      121 +.I n
      122 +or fewer bytes complete a valid character (which is the
  80  123  value stored); the value returned is the number of bytes that complete the
  81  124  character.
  82      -.RE
  83      -
  84      -.sp
  85      -.ne 2
  86      -.na
  87      -\fB\fB(size_t)\(mi2\fR\fR
  88      -.ad
  89      -.RS 17n
  90      -If the next \fIn\fR bytes contribute to an incomplete but potentially valid
  91      -character, and all \fIn\fR bytes have been processed (no value is stored).
  92      -When \fIn\fR has at least the value of the \fBMB_CUR_MAX\fR macro, this case
  93      -can only occur if  \fIs\fR points at a sequence of redundant shift sequences
      125 +.IP \fB(size_t)\(mi2\fR
      126 +If the next
      127 +.I n
      128 +bytes contribute to an incomplete but potentially valid
      129 +character, and all
      130 +.I n
      131 +bytes have been processed (no value is stored).
      132 +When
      133 +.I n
      134 +has at least the value of the
      135 +.B MB_CUR_MAX
      136 +macro, this case can only occur if
      137 +.I s
      138 +points at a sequence of redundant shift sequences
  94  139  (for implementations with state-dependent encodings).
  95      -.RE
  96      -
  97      -.sp
  98      -.ne 2
  99      -.na
 100      -\fB\fB(size_t)\(mi1\fR\fR
 101      -.ad
 102      -.RS 17n
      140 +.IP \fB(size_t)\(mi1\fR
 103  141  If an encoding error occurs, in which case the next \fIn\fR or fewer bytes do
 104  142  not contribute to a complete and valid  character (no value is stored).  In
 105      -this case, \fBEILSEQ\fR is stored in \fBerrno\fR and the conversion state is
 106      -undefined.
 107      -.RE
 108      -
      143 +this case,
      144 +.B EILSEQ
      145 +is stored in
      146 +.B errno
      147 +and the conversion state is undefined.
 109  148  .SH ERRORS
 110      -.sp
 111  149  .LP
 112      -The \fBmbrtowc()\fR function may fail if:
 113      -.sp
 114      -.ne 2
 115      -.na
 116      -\fB\fBEINVAL\fR\fR
 117      -.ad
 118      -.RS 10n
 119      -The \fIps\fR argument points to an object that contains an invalid conversion
      150 +The
      151 +.B mbrtowc()
      152 +and
      153 +.B mbrtowc_l()
      154 +functions may fail if:
      155 +.IP \fBEINVAL\fR
      156 +The
      157 +.I ps
      158 +argument points to an object that contains an invalid conversion
 120  159  state.
 121      -.RE
 122      -
 123      -.sp
 124      -.ne 2
 125      -.na
 126      -\fB\fBEILSEQ\fR\fR
 127      -.ad
 128      -.RS 10n
      160 +.IP \fBEILSEQ\fR
 129  161  Invalid character sequence is detected.
 130      -.RE
 131      -
 132  162  .SH ATTRIBUTES
 133      -.sp
 134  163  .LP
 135  164  See \fBattributes\fR(5) for descriptions of the following attributes:
 136      -.sp
 137      -
 138      -.sp
 139  165  .TS
 140  166  box;
 141  167  c | c
 142  168  l | l .
 143  169  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 144  170  _
 145      -Interface Stability     Standard
      171 +Interface Stability     See below.
 146  172  _
 147      -MT-Level        See NOTES below
      173 +MT-Level        See below.
 148  174  .TE
 149  175  
 150      -.SH SEE ALSO
 151      -.sp
 152  176  .LP
 153      -\fBmbsinit\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5),
 154      -\fBstandards\fR(5)
 155      -.SH NOTES
 156      -.sp
      177 +The
      178 +.B mbrtowc()
      179 +function is Standard.  The
      180 +.B mbrtowc_l()
      181 +function is Uncommitted.
 157  182  .LP
 158      -If \fIps\fR is not a null pointer, \fBmbrtowc()\fR uses the \fBmbstate_t\fR
 159      -object pointed to by \fIps\fR and the function can be used safely in
 160      -multithreaded applications, as long as \fBsetlocale\fR(3C) is not being called
 161      -to change the locale. If \fIps\fR is a null pointer, \fBmbrtowc()\fR uses its
 162      -internal \fBmbstate_t\fR object and the function is Unsafe in multithreaded
 163      -applications.
      183 +If
      184 +.I ps
      185 +is a null pointer, these functions are Unsafe for use in
      186 +multithreaded applications.  Otherwise they are MT-Safe.
      187 +.SH SEE ALSO
      188 +.LP
      189 +.BR mbsinit (3C),
      190 +.BR newlocale (3C),
      191 +.BR setlocale (3C),
      192 +.BR uselocale (3C),
      193 +.BR attributes (5),
      194 +.BR environ (5),
      195 +.BR standards (5)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX