diff options
Diffstat (limited to 'devdocs/c/string%2Fwide%2Fwcscpy.html')
| -rw-r--r-- | devdocs/c/string%2Fwide%2Fwcscpy.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fwide%2Fwcscpy.html b/devdocs/c/string%2Fwide%2Fwcscpy.html new file mode 100644 index 00000000..0242fb59 --- /dev/null +++ b/devdocs/c/string%2Fwide%2Fwcscpy.html @@ -0,0 +1,70 @@ + <h1 id="firstHeading" class="firstHeading">wcscpy, wcscpy_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">wchar_t* wcscpy( wchar_t* dest, const wchar_t* src );</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">wchar_t* wcscpy( wchar_t* restrict dest, const wchar_t* restrict src );</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 wcscpy_s( wchar_t* restrict dest, rsize_t destsz, + const wchar_t* restrict src );</pre> +</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <div class="t-li1"> +<span class="t-li">1)</span> Copies the wide string pointed to by <code>src</code> (including the terminating null wide character) to wide character array pointed to by <code>dest</code>. The behavior is undefined if the <code>dest</code> array is not large enough. The behavior is undefined if the strings overlap.</div> <div class="t-li1"> +<span class="t-li">2)</span> Same as <span class="t-v">(1)</span>, except that it may clobber the rest of the destination array with unspecified values and that 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: <dl> +<dd> +<ul> +<li> <code>src</code> or <code>dest</code> is a null pointer </li> +<li> <code>destsz</code> is zero or greater than <code>RSIZE_MAX / sizeof(wchar_t)</code> </li> +<li> <code>destsz</code> is less or equal <code>wcsnlen_s(src, destsz)</code>, in other words, truncation would occur </li> +<li> overlap would occur between the source and the destination strings </li> +</ul> </dd> +<dd>As with all bounds-checked functions, <code>wcscpy_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> +</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> dest </td> <td> - </td> <td> pointer to the wide character array to copy to </td> +</tr> <tr class="t-par"> <td> src </td> <td> - </td> <td> pointer to the null-terminated wide string to copy from </td> +</tr> <tr class="t-par"> <td> destsz </td> <td> - </td> <td> maximum number of characters to write, typically the size of the destination buffer </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <div class="t-li1"> +<span class="t-li">1)</span> returns a copy of <code>dest</code> +</div> <div class="t-li1"> +<span class="t-li">2)</span> returns zero on success, returns non-zero on error. Also, on error, writes <code>L'\0'</code> to <code>dest[0]</code> (unless <code>dest</code> is a null pointer or <code>destsz</code> is zero or greater than <code>RMAX_SIZE / sizeof(wchar_t)</code>).</div> <h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <locale.h> +#include <stdio.h> +#include <wchar.h> + +int main(void) +{ + wchar_t* src = L"犬 means dog"; +// src[0] = L'狗' ; // this would be undefined behavior + wchar_t dst[wcslen(src) + 1]; // +1 for the null terminator + wcscpy(dst, src); + dst[0] = L'狗'; // OK + + setlocale(LC_ALL, "en_US.utf8"); + printf("src = %ls\ndst = %ls\n", src, dst); +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">src = 犬 means dog +dst = 狗 means dog</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C23 standard (ISO/IEC 9899:2023): </li> +<ul> +<li> 7.29.4.1.2 The wcscpy function (p: TBD) </li> +<li> K.3.9.2.1.1 The wcscpy_s function (p: TBD) </li> +</ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul> +<li> 7.29.4.1.2 The wcscpy function (p: TBD) </li> +<li> K.3.9.2.1.1 The wcscpy_s function (p: TBD) </li> +</ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 7.29.4.1.2 The wcscpy function (p: 430) </li> +<li> K.3.9.2.1.1 The wcscpy_s function (p: 639) </li> +</ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.24.4.1.2 The wcscpy function (p: 376) </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="wcsncpy" title="c/string/wide/wcsncpy"> <span class="t-lines"><span>wcsncpy</span><span>wcsncpy_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> copies a certain amount of wide characters from one string to another <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="wmemcpy" title="c/string/wide/wmemcpy"> <span class="t-lines"><span>wmemcpy</span><span>wmemcpy_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> copies a certain amount of wide characters between two non-overlapping arrays <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="../byte/strcpy" title="c/string/byte/strcpy"> <span class="t-lines"><span>strcpy</span><span>strcpy_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> copies one string to another <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/wide/wcscpy" title="cpp/string/wide/wcscpy">C++ documentation</a></span> for <code>wcscpy</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/wide/wcscpy" class="_attribution-link">https://en.cppreference.com/w/c/string/wide/wcscpy</a> + </p> +</div> |
