errno_t wmemcpy_s( wchar_t *restrict dest, rsize_t destsz,
const wchar_t *restrict src, rsize_t count );
1) Copies exactly count
successive wide characters from the wide character array pointed to by src
to the wide character array pointed to by dest
. If the objects overlap, the behavior is undefined. If count
is zero, the function does nothing.
Same as
(1), except that the following errors are detected at runtime and call the currently installed
constraint handlerfunction:
src
or dest
is a null pointerdestsz
or count
is greater than RSIZE_MAX/sizeof(wchar_t)count
is greater than destsz
(overflow would occur)wmemcpy_s
is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including <wchar.h>.
1) returns a copy of dest
2) returns zero on success, returns non-zero on error. Also, on error, fills the entire dst
up to and not including dst+dstsz with null wide characters, L'\0' (unless dest
is null or destsz
is greater than RSIZE_MAX/sizeof(wchar_t))
This function's analog for byte strings is strncpy, not strcpy.
This function is not locale-sensitive and pays no attention to the values of the wchar_t objects it copies: nulls as well as invalid characters are copied too.
[edit] Example#include <stdio.h> #include <wchar.h> #include <locale.h> int main(void) { wchar_t from1[] = L"नमसà¥à¤¤à¥"; size_t sz1 = sizeof from1 / sizeof *from1; wchar_t from2[] = L"Ô²Õ¡ÖÖ"; size_t sz2 = sizeof from2 / sizeof *from2; wchar_t to[sz1 + sz2]; wmemcpy(to, from1, sz1); // copy from1, along with its null terminator wmemcpy(to + sz1, from2, sz2); // append from2, along with its null terminator setlocale(LC_ALL, "en_US.utf8"); printf("Wide array contains: "); for(size_t n = 0; n < sizeof to / sizeof *to; ++n) if(to[n]) printf("%lc", to[n]); else printf("\\0"); printf("\n"); }
Possible output:
Wide array contains: नमसà¥à¤¤à¥\0Ô²Õ¡ÖÖ\0[edit] References
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4