You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 line
5.7KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>mbsrtowcs (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="mbsrtowcs (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="mbsrtowcs (The Red Hat newlib C Library)">
  9. <meta name="resource-type" content="document">
  10. <meta name="distribution" content="global">
  11. <meta name="Generator" content="makeinfo">
  12. <link href="index.html#Top" rel="start" title="Top">
  13. <link href="Document-Index.html#Document-Index" rel="index" title="Document Index">
  14. <link href="Document-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
  15. <link href="Stdlib.html#Stdlib" rel="up" title="Stdlib">
  16. <link href="mbstowcs.html#mbstowcs" rel="next" title="mbstowcs">
  17. <link href="mblen.html#mblen" rel="prev" title="mblen">
  18. <style type="text/css">
  19. <!--
  20. a.summary-letter {text-decoration: none}
  21. blockquote.indentedblock {margin-right: 0em}
  22. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  23. blockquote.smallquotation {font-size: smaller}
  24. div.display {margin-left: 3.2em}
  25. div.example {margin-left: 3.2em}
  26. div.lisp {margin-left: 3.2em}
  27. div.smalldisplay {margin-left: 3.2em}
  28. div.smallexample {margin-left: 3.2em}
  29. div.smalllisp {margin-left: 3.2em}
  30. kbd {font-style: oblique}
  31. pre.display {font-family: inherit}
  32. pre.format {font-family: inherit}
  33. pre.menu-comment {font-family: serif}
  34. pre.menu-preformatted {font-family: serif}
  35. pre.smalldisplay {font-family: inherit; font-size: smaller}
  36. pre.smallexample {font-size: smaller}
  37. pre.smallformat {font-family: inherit; font-size: smaller}
  38. pre.smalllisp {font-size: smaller}
  39. span.nolinebreak {white-space: nowrap}
  40. span.roman {font-family: initial; font-weight: normal}
  41. span.sansserif {font-family: sans-serif; font-weight: normal}
  42. ul.no-bullet {list-style: none}
  43. -->
  44. </style>
  45. </head>
  46. <body lang="en">
  47. <a name="mbsrtowcs"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="mbstowcs.html#mbstowcs" accesskey="n" rel="next">mbstowcs</a>, Previous: <a href="mblen.html#mblen" accesskey="p" rel="prev">mblen</a>, Up: <a href="Stdlib.html#Stdlib" accesskey="u" rel="up">Stdlib</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  51. </div>
  52. <hr>
  53. <a name="mbsrtowcs_002c-mbsnrtowcs_002d_002d_002dconvert-a-character-string-to-a-wide_002dcharacter-string"></a>
  54. <h3 class="section">2.28 <code>mbsrtowcs</code>, <code>mbsnrtowcs</code>&mdash;convert a character string to a wide-character string</h3>
  55. <a name="index-mbsrtowcs"></a>
  56. <a name="index-_005fmbsrtowcs_005fr"></a>
  57. <a name="index-mbsnrtowcs"></a>
  58. <a name="index-_005fmbsnrtowcs_005fr"></a>
  59. <p><strong>Synopsis</strong>
  60. </p><div class="example">
  61. <pre class="example">#include &lt;wchar.h&gt;
  62. size_t mbsrtowcs(wchar_t *__restrict <var>dst</var>,
  63. const char **__restrict <var>src</var>,
  64. size_t <var>len</var>,
  65. mbstate_t *__restrict <var>ps</var>);
  66. #include &lt;wchar.h&gt;
  67. size_t _mbsrtowcs_r(struct _reent *<var>ptr</var>, wchar_t *<var>dst</var>,
  68. const char **<var>src</var>, size_t <var>len</var>,
  69. mbstate_t *<var>ps</var>);
  70. #include &lt;wchar.h&gt;
  71. size_t mbsnrtowcs(wchar_t *__ restrict <var>dst</var>,
  72. const char **__restrict <var>src</var>, size_t <var>nms</var>,
  73. size_t <var>len</var>, mbstate_t *__restrict <var>ps</var>);
  74. #include &lt;wchar.h&gt;
  75. size_t _mbsnrtowcs_r(struct _reent *<var>ptr</var>, wchar_t *<var>dst</var>,
  76. const char **<var>src</var>, size_t <var>nms</var>,
  77. size_t <var>len</var>, mbstate_t *<var>ps</var>);
  78. </pre></div>
  79. <p><strong>Description</strong><br>
  80. The <code>mbsrtowcs</code> function converts a sequence of multibyte characters
  81. pointed to indirectly by <var>src</var> into a sequence of corresponding wide
  82. characters and stores at most <var>len</var> of them in the wchar_t array pointed
  83. to by <var>dst</var>, until it encounters a terminating null character (&rsquo;\0&rsquo;).
  84. </p>
  85. <p>If <var>dst</var> is NULL, no characters are stored.
  86. </p>
  87. <p>If <var>dst</var> is not NULL, the pointer pointed to by <var>src</var> is updated to point
  88. to the character after the one that conversion stopped at. If conversion
  89. stops because a null character is encountered, *<var>src</var> is set to NULL.
  90. </p>
  91. <p>The mbstate_t argument, <var>ps</var>, is used to keep track of the shift state. If
  92. it is NULL, <code>mbsrtowcs</code> uses an internal, static mbstate_t object, which
  93. is initialized to the initial conversion state at program startup.
  94. </p>
  95. <p>The <code>mbsnrtowcs</code> function behaves identically to <code>mbsrtowcs</code>, except that
  96. conversion stops after reading at most <var>nms</var> bytes from the buffer pointed
  97. to by <var>src</var>.
  98. </p>
  99. <br>
  100. <p><strong>Returns</strong><br>
  101. The <code>mbsrtowcs</code> and <code>mbsnrtowcs</code> functions return the number of wide
  102. characters stored in the array pointed to by <var>dst</var> if successful, otherwise
  103. it returns (size_t)-1.
  104. </p>
  105. <br>
  106. <p><strong>Portability</strong><br>
  107. <code>mbsrtowcs</code> is defined by the C99 standard.
  108. <code>mbsnrtowcs</code> is defined by the POSIX.1-2008 standard.
  109. </p>
  110. <br>
  111. <hr>
  112. <div class="header">
  113. <p>
  114. Next: <a href="mbstowcs.html#mbstowcs" accesskey="n" rel="next">mbstowcs</a>, Previous: <a href="mblen.html#mblen" accesskey="p" rel="prev">mblen</a>, Up: <a href="Stdlib.html#Stdlib" accesskey="u" rel="up">Stdlib</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  115. </div>
  116. </body>
  117. </html>