logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

mbrtowc.3p (5041B)


  1. '\" et
  2. .TH MBRTOWC "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. mbrtowc
  12. \(em convert a character to a wide-character code (restartable)
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <wchar.h>
  17. .P
  18. size_t mbrtowc(wchar_t *restrict \fIpwc\fP, const char *restrict \fIs\fP,
  19. size_t \fIn\fP, mbstate_t *restrict \fIps\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The functionality described on this reference page is aligned with the
  23. ISO\ C standard. Any conflict between the requirements described here and the
  24. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  25. .P
  26. If
  27. .IR s
  28. is a null pointer, the
  29. \fImbrtowc\fR()
  30. function shall be equivalent to the call:
  31. .sp
  32. .RS 4
  33. .nf
  34. mbrtowc(NULL, "", 1, ps)
  35. .fi
  36. .P
  37. .RE
  38. .P
  39. In this case, the values of the arguments
  40. .IR pwc
  41. and
  42. .IR n
  43. are ignored.
  44. .P
  45. If
  46. .IR s
  47. is not a null pointer, the
  48. \fImbrtowc\fR()
  49. function shall inspect at most
  50. .IR n
  51. bytes beginning at the byte pointed to by
  52. .IR s
  53. to determine the number of bytes needed to complete the next character
  54. (including any shift sequences). If the function determines that the
  55. next character is completed, it shall determine the value of the
  56. corresponding wide character and then, if
  57. .IR pwc
  58. is not a null pointer, shall store that value in the object pointed to by
  59. .IR pwc .
  60. If the corresponding wide character is the null wide character, the
  61. resulting state described shall be the initial conversion state.
  62. .P
  63. If
  64. .IR ps
  65. is a null pointer, the
  66. \fImbrtowc\fR()
  67. function shall use its own internal
  68. .BR mbstate_t
  69. object, which shall be initialized at program start-up to the initial
  70. conversion state. Otherwise, the
  71. .BR mbstate_t
  72. object pointed to by
  73. .IR ps
  74. shall be used to completely describe the current conversion state of
  75. the associated character sequence. The implementation shall behave as
  76. if no function defined in this volume of POSIX.1\(hy2017 calls
  77. \fImbrtowc\fR().
  78. .P
  79. The behavior of this function is affected by the
  80. .IR LC_CTYPE
  81. category of the current locale.
  82. .P
  83. The
  84. \fImbrtowc\fR()
  85. function need not be thread-safe if called with a NULL
  86. .IR ps
  87. argument.
  88. .P
  89. The
  90. \fImbrtowc\fR()
  91. function shall not change the setting of
  92. .IR errno
  93. if successful.
  94. .SH "RETURN VALUE"
  95. The
  96. \fImbrtowc\fR()
  97. function shall return the first of the following that applies:
  98. .IP 0 12
  99. If the next
  100. .IR n
  101. or fewer bytes complete the character that corresponds to the null wide
  102. character (which is the value stored).
  103. .IP "between 1 and \fIn\fR inclusive" 12
  104. .br
  105. If the next
  106. .IR n
  107. or fewer bytes complete a valid character (which is the value stored);
  108. the value returned shall be the number of bytes that complete the
  109. character.
  110. .IP "(\fBsize_t\fP)\-2" 12
  111. If the next
  112. .IR n
  113. bytes contribute to an incomplete but potentially valid character, and
  114. all
  115. .IR n
  116. bytes have been processed (no value is stored). When
  117. .IR n
  118. has at least the value of the
  119. {MB_CUR_MAX}
  120. macro, this case can only occur if
  121. .IR s
  122. points at a sequence of redundant shift sequences (for implementations
  123. with state-dependent encodings).
  124. .IP "(\fBsize_t\fP)\-1" 12
  125. If an encoding error occurs, in which case the next
  126. .IR n
  127. or fewer bytes do not contribute to a complete and valid character (no
  128. value is stored). In this case,
  129. .BR [EILSEQ]
  130. shall be stored in
  131. .IR errno
  132. and the conversion state is undefined.
  133. .SH ERRORS
  134. The
  135. \fImbrtowc\fR()
  136. function shall fail if:
  137. .TP
  138. .BR EILSEQ
  139. An invalid character sequence is detected.
  140. In the POSIX locale an
  141. .BR [EILSEQ]
  142. error cannot occur since all byte values are valid characters.
  143. .P
  144. The
  145. \fImbrtowc\fR()
  146. function may fail if:
  147. .TP
  148. .BR EINVAL
  149. .IR ps
  150. points to an object that contains an invalid conversion state.
  151. .LP
  152. .IR "The following sections are informative."
  153. .SH EXAMPLES
  154. None.
  155. .SH "APPLICATION USAGE"
  156. None.
  157. .SH RATIONALE
  158. None.
  159. .SH "FUTURE DIRECTIONS"
  160. None.
  161. .SH "SEE ALSO"
  162. .IR "\fImbsinit\fR\^(\|)",
  163. .IR "\fImbsrtowcs\fR\^(\|)"
  164. .P
  165. The Base Definitions volume of POSIX.1\(hy2017,
  166. .IR "\fB<wchar.h>\fP"
  167. .\"
  168. .SH COPYRIGHT
  169. Portions of this text are reprinted and reproduced in electronic form
  170. from IEEE Std 1003.1-2017, Standard for Information Technology
  171. -- Portable Operating System Interface (POSIX), The Open Group Base
  172. Specifications Issue 7, 2018 Edition,
  173. Copyright (C) 2018 by the Institute of
  174. Electrical and Electronics Engineers, Inc and The Open Group.
  175. In the event of any discrepancy between this version and the original IEEE and
  176. The Open Group Standard, the original IEEE and The Open Group Standard
  177. is the referee document. The original Standard can be obtained online at
  178. http://www.opengroup.org/unix/online.html .
  179. .PP
  180. Any typographical or formatting errors that appear
  181. in this page are most likely
  182. to have been introduced during the conversion of the source files to
  183. man page format. To report such errors, see
  184. https://www.kernel.org/doc/man-pages/reporting_bugs.html .