forked from kovacsv/VisualScriptEngineWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (22 loc) · 760 Bytes
/
main.cpp
File metadata and controls
30 lines (22 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// https://github.com/emscripten-core/emscripten/issues/11947
#include <iostream>
#include <locale>
#include <codecvt>
std::string WStringToString (const std::wstring& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> convert;
return std::string (convert.to_bytes (str));
}
int main (int, char**)
{
setlocale (LC_ALL, "");
std::cout << "BEGIN" << std::endl;
std::wstring directString (L"Aa\xc1");
std::cout << WStringToString (directString) << std::endl;
wchar_t formattedStringBuf[32];
swprintf (formattedStringBuf, 32, L"%ls", directString.c_str ());
std::wstring formattedString (formattedStringBuf);
std::cout << WStringToString (formattedString) << std::endl;
std::cout << "END" << std::endl;
return EXIT_SUCCESS;
}