Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
wcstombs_s wide string conversion with multibyte chars and locale + concatenation
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <Windows.h> int main() { wchar_t pLocale[256]; GetSystemDefaultLocaleName(pLocale, sizeof(pLocale)); std::wcout << L"Current locale: " << pLocale << std::endl; const wchar_t* ppInput[] = { L"José", L"測試", L"αβ", L"Środa" }; for(size_t i = 0; i < _countof(ppInput); ++i) { std::wcout << L"Original string: " << ppInput[i] << std::endl; char pOutput[256] = { '\0' }; size_t bytesConverted = 0; size_t ret = wcstombs_s(&bytesConverted, pOutput, sizeof(pOutput), ppInput[i], sizeof(pOutput) - 1); std::cout << "\tret = " << ret << ", bytesConverted = " << bytesConverted << ", output = " << pOutput << std::endl; strncat_s(pOutput, sizeof(pOutput), "-concatenated", _TRUNCATE); std::cout << "\tconcatenated = " << pOutput << std::endl; } }
run
|
edit
|
history
|
help
1
C++ exception
const_pointer_cast
MSVC_example_fscanf_s_and_chars_wchars
Code
move swap
javascritp
VC typeid example
Regex pipe and tabs c++
parantheses matching using stack in C++ - test
cv5