diff options
Diffstat (limited to 'devdocs/c/string%2Fmultibyte%2Fwcsrtombs.html')
| -rw-r--r-- | devdocs/c/string%2Fmultibyte%2Fwcsrtombs.html | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/devdocs/c/string%2Fmultibyte%2Fwcsrtombs.html b/devdocs/c/string%2Fmultibyte%2Fwcsrtombs.html deleted file mode 100644 index fd435f8a..00000000 --- a/devdocs/c/string%2Fmultibyte%2Fwcsrtombs.html +++ /dev/null @@ -1,83 +0,0 @@ - <h1 id="firstHeading" class="firstHeading">wcsrtombs, wcsrtombs_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><wchar.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl-rev-aux"> <td></td> <td rowspan="3">(1)</td> <td></td> </tr> <tr class="t-dcl t-since-c95 t-until-c99"> <td><pre data-language="c">size_t wcsrtombs( char *dst, const wchar_t **src, size_t len, mbstate_t* ps );</pre></td> <td> -<span class="t-mark-rev t-since-c95">(since C95)</span> <br><span class="t-mark-rev t-until-c99">(until C99)</span> -</td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">size_t wcsrtombs( char *restrict dst, const wchar_t **restrict src, size_t len, - mbstate_t *restrict ps );</pre> -</td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">errno_t wcsrtombs_s( size_t *restrict retval, char *restrict dst, rsize_t dstsz, - const wchar_t **restrict src, rsize_t len, - mbstate_t *restrict ps );</pre> -</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <span class="t-li">1)</span> Converts a sequence of wide characters from the array whose first element is pointed to by <code>*src</code> to its narrow multibyte representation that begins in the conversion state described by <code>*ps</code>. If <code>dst</code> is not null, converted characters are stored in the successive elements of the char array pointed to by <code>dst</code>. No more than <code>len</code> bytes are written to the destination array. Each character is converted as if by a call to <code><a href="wcrtomb" title="c/string/multibyte/wcrtomb">wcrtomb</a></code>. The conversion stops if: <ul> -<li> The null character <code>L'\0'</code> was converted and stored. The bytes stored in this case are the unshift sequence (if necessary) followed by <code>'\0'</code>, <code>*src</code> is set to null pointer value and <code>*ps</code> represents the initial shift state. </li> -<li> A <code>wchar_t</code> was found that does not correspond to a valid character in the current C locale. <code>*src</code> is set to point at the first unconverted wide character. </li> -<li> the next multibyte character to be stored would exceed <code>len</code>. <code>*src</code> is set to point at the first unconverted wide character. This condition is not checked if <code>dst</code> is a null pointer.</li> -</ul> <span class="t-li">2)</span> Same as <span class="t-v">(1)</span>, except that <ul> -<li> the function returns its result as an out-parameter <code>retval</code> </li> -<li> if the conversion stops without writing a null character, the function will store <code>'\0'</code> in the next byte in <code>dst</code>, which may be <code>dst[len]</code> or <code>dst[dstsz]</code>, whichever comes first (meaning up to len+1/dstsz+1 total bytes may be written). In this case, there may be no unshift sequence written before the terminating null. </li> -<li> the function clobbers the destination array from the terminating null and until <code>dstsz</code> </li> -<li> If <code>src</code> and <code>dst</code> overlap, the behavior is unspecified. </li> -<li> the following errors are detected at runtime and call the currently installed <a href="../../error/set_constraint_handler_s" title="c/error/set constraint handler s">constraint handler</a> function: </li> -</ul> <dl> -<dd> -<ul> -<li> <code>retval</code>, <code>ps</code>, <code>src</code>, or <code>*src</code> is a null pointer </li> -<li> <code>dstsz</code> or <code>len</code> is greater than <code>RSIZE_MAX</code> (unless <code>dst</code> is null) </li> -<li> <code>dstsz</code> is not zero (unless <code>dst</code> is null) </li> -<li> <code>len</code> is greater than <code>dstsz</code> and the conversion does not encounter null or encoding error in the <code>src</code> array by the time <code>dstsz</code> is reached (unless <code>dst</code> is null) </li> -</ul> </dd> -<dd>As with all bounds-checked functions, <code>wcsrtombs_s</code> only guaranteed to be available if <code>__STDC_LIB_EXT1__</code> is defined by the implementation and if the user defines <code>__STDC_WANT_LIB_EXT1__</code> to the integer constant <code>1</code> before including <a href="../wide" title="c/string/wide"><code><wchar.h></code></a>.</dd> -</dl> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> dst </td> <td> - </td> <td> pointer to narrow character array where the multibyte characters will be stored </td> -</tr> <tr class="t-par"> <td> src </td> <td> - </td> <td> pointer to pointer to the first element of a null-terminated wide string </td> -</tr> <tr class="t-par"> <td> len </td> <td> - </td> <td> number of bytes available in the array pointed to by dst </td> -</tr> <tr class="t-par"> <td> ps </td> <td> - </td> <td> pointer to the conversion state object </td> -</tr> <tr class="t-par"> <td> dstsz </td> <td> - </td> <td> max number of bytes that will be written (size of the <code>dst</code> array) </td> -</tr> <tr class="t-par"> <td> retval </td> <td> - </td> <td> pointer to a <code><a href="../../types/size_t" title="c/types/size t">size_t</a></code> object where the result will be stored </td> -</tr> -</table> <h3 id="Return_value"> Return value</h3> <div class="t-li1"> -<span class="t-li">1)</span> On success, returns the number of bytes (including any shift sequences, but excluding the terminating <code>'\0'</code>) written to the character array whose first element is pointed to by <code>dst</code>. If <code>dst</code> is a null pointer, returns the number of bytes that would have been written. On conversion error (if invalid wide character was encountered), returns <code><span class="br0">(</span><a href="http://en.cppreference.com/w/c/types/size_t"><span class="kw100">size_t</span></a><span class="br0">)</span><span class="sy2">-</span><span class="nu0">1</span></code>, stores <code><a href="../../error/errno_macros" title="c/error/errno macros">EILSEQ</a></code> in <code><a href="../../error/errno" title="c/error/errno">errno</a></code>, and leaves <code>*ps</code> in unspecified state.</div> <div class="t-li1"> -<span class="t-li">2)</span> Returns zero on success (in which case the number of bytes excluding terminating zero that were, or would be written to <code>dst</code>, is stored in <code>*retval</code>), non-zero on error. In case of a runtime constraint violation, stores <code><span class="br0">(</span><a href="http://en.cppreference.com/w/c/types/size_t"><span class="kw100">size_t</span></a><span class="br0">)</span><span class="sy2">-</span><span class="nu0">1</span></code> in <code>*retval</code> (unless <code>retval</code> is null) and sets <code>dst[0]</code> to <code>'\0'</code> (unless <code>dst</code> is null or <code>dstmax</code> is zero or greater than <code>RSIZE_MAX</code>)</div> <h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> -#include <locale.h> -#include <string.h> -#include <wchar.h> - -void print_wide(const wchar_t* wstr) -{ - mbstate_t state; - memset(&state, 0, sizeof state); - size_t len = 1 + wcsrtombs(NULL, &wstr, 0, &state); - char mbstr[len]; - wcsrtombs(mbstr, &wstr, len, &state); - printf("Multibyte string: %s\n", mbstr); - printf("Length, including '\\0': %zu\n", len); -} - -int main(void) -{ - setlocale(LC_ALL, "en_US.utf8"); - print_wide(L"z\u00df\u6c34\U0001f34c"); // or L"zß水🍌" -}</pre></div> <p>Output:</p> -<div class="text source-text"><pre data-language="c">Multibyte string: zß水🍌 -Length, including '\0': 11</pre></div> </div> <h3 id="References"> References</h3> <ul> -<li> C17 standard (ISO/IEC 9899:2018): </li> -<ul> -<li> 7.29.6.4.2 The wcsrtombs function (p: 324-325) </li> -<li> K.3.9.3.2.2 The wcsrtombs_s function (p: 471-472) </li> -</ul> -<li> C11 standard (ISO/IEC 9899:2011): </li> -<ul> -<li> 7.29.6.4.2 The wcsrtombs function (p: 446) </li> -<li> K.3.9.3.2.2 The wcsrtombs_s function (p: 649-651) </li> -</ul> -<li> C99 standard (ISO/IEC 9899:1999): </li> -<ul><li> 7.24.6.4.2 The wcsrtombs function (p: 392) </li></ul> -</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="wcstombs" title="c/string/multibyte/wcstombs"> <span class="t-lines"><span>wcstombs</span><span>wcstombs_s</span></span></a></div> -<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> converts a wide string to narrow multibyte character string <br> <span class="t-mark">(function)</span> </td> -</tr> <tr class="t-dsc"> <td> <div><a href="wcrtomb" title="c/string/multibyte/wcrtomb"> <span class="t-lines"><span>wcrtomb</span><span>wcrtomb_s</span></span></a></div> -<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> converts a wide character to its multibyte representation, given state <br> <span class="t-mark">(function)</span> </td> -</tr> <tr class="t-dsc"> <td> <div><a href="mbsrtowcs" title="c/string/multibyte/mbsrtowcs"> <span class="t-lines"><span>mbsrtowcs</span><span>mbsrtowcs_s</span></span></a></div> -<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> converts a narrow multibyte character string to wide string, given state <br> <span class="t-mark">(function)</span> </td> -</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/multibyte/wcsrtombs" title="cpp/string/multibyte/wcsrtombs">C++ documentation</a></span> for <code>wcsrtombs</code> </td> -</tr> </table> <div class="_attribution"> - <p class="_attribution-p"> - © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> - <a href="https://en.cppreference.com/w/c/string/multibyte/wcsrtombs" class="_attribution-link">https://en.cppreference.com/w/c/string/multibyte/wcsrtombs</a> - </p> -</div> |
