Add UTF8,16,32 support to the Memory Visualizer.

This commit is contained in:
Ernie Pasveer
2023-12-27 12:31:31 -06:00
parent c55fe5eeac
commit a8256cc84a
9 changed files with 184 additions and 43 deletions
+31
View File
@@ -0,0 +1,31 @@
#include <iostream>
#include <stdlib.h>
int main (int argc, char* argv[]) {
std::wstring w_redrum = { L"All work and no play makes Jack a dull boy.\n" };
std::string u8_redrum = { u8"All work and no play makes Jack a dull boy.\n" };
std::u16string u16_redrum = { u"All work and no play makes Jack a dull boy.\n" };
std::u32string u32_redrum = { U"All work and no play makes Jack a dull boy.\n" };
std::u16string u16_hungry = { u"nǐ chīle ma.\n" };
// Do something with the strings so they don't get optimized out.
std::cout << w_redrum.length() << std::endl;
std::cout << u8_redrum.length() << std::endl;
std::cout << u16_redrum.length() << std::endl;
std::cout << u32_redrum.length() << std::endl;
std::cout << u16_hungry.length() << std::endl;
const wchar_t* w_ptr = w_redrum.data();
const char* u8_ptr = u8_redrum.data();
const char16_t* u16_ptr = u16_redrum.data();
const char32_t* u32_ptr = u32_redrum.data();
const char16_t* hungry_ptr = u16_hungry.data();
return 0;
}