Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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"測試", 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 << "Concatenated string: " << pOutput << std::endl; } }
run
|
edit
|
history
|
help
0
const_pointer_cast
Fast sine to fill array (sin/cos pair)
fun
No UD
student.h
StreamParam
Computing the factorial of an integer using factorial and iteration
LinkedList
WinAPI not accessible
Copy elision sample modern C++