Created
March 28, 2016 08:09
-
-
Save xylcbd/7b1dd4005da465d0b1df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
static std::string convertUtf16ToLocal(const unsigned short data) | |
{ | |
char dstData[3]; | |
::wcstombs(dstData, (const wchar_t *)&data, 2); | |
dstData[2] = '\0'; | |
return dstData; | |
} | |
static void dumpUtf16Charset() | |
{ | |
::setlocale(LC_ALL, ""); | |
std::ofstream ofs("d:/utf16.set",std::ios::binary); | |
for (int i = 0; i < std::numeric_limits<unsigned short>::max();i++) | |
{ | |
const auto localChar = convertUtf16ToLocal(i); | |
ofs.write(localChar.c_str(), localChar.size()); | |
ofs << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment