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.
[edit] Parameters dest - pointer to the wide character array to copy to src - pointer to the wide character array to copy from count - number of wide characters to copy [edit] Return valuedest
[edit] NotesThis function's analog for byte strings is std::strncpy, not std::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 <clocale> #include <cwchar> #include <iostream> #include <iterator> #include <locale> int main(void) { const wchar_t from1[] = L"नमसà¥à¤¤à¥"; const wchar_t from2[] = L"Ô²Õ¡ÖÖ"; const std::size_t sz1 = std::size(from1); const std::size_t sz2 = std::size(from2); wchar_t to[sz1 + sz2]; std::wmemcpy(to, from1, sz1); // copy from1, along with its null terminator std::wmemcpy(to + sz1, from2, sz2); // append from2, along with its null terminator std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << L"Wide array contains: "; for (std::size_t n = 0; n < std::size(to); ++n) if (to[n]) std::wcout << to[n]; else std::wcout << L"\\0"; std::wcout << L'\n'; }
Possible output:
Wide array contains: नमसà¥à¤¤à¥\0Ô²Õ¡ÖÖ\0[edit] See also copies a certain amount of characters from one string to another
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