I read a file using ifstream's read method into a char* memory block. I call my GetChar method on each char in the memory block to write to a wstring. I am trying to write the unicode characters to the screen (at least I think they are unicode, please correct me if I am wrong - oh no it looks like I was wrong its extended ascii). Unfortunately the only way I've got it to work is to hard code the unicode characters in a switch statement, but I'd rather it work for any character, not just the ones I've encountered and added by hard coding them.
Here is what I'm currently using:
std::wstring GetChar(char o)
{
switch (o)
{
case 0x0D:
return L"♪";
case 0x0A:
return L"◙";
case -38:
return L"┌";
case -60:
return L"─";
case -77:
return L"│";
case -65:
return L"┐";
case -61:
return L"├";
case -76:
return L"┤";
case -2:
return L"■";
}
std::wstring tmp_string(1, o);
return tmp_string;
}
Any idea how to convert -38 to L"┌" in a generic way? [Edit] I discovered that my mappings are actually extended ascii!, see the webpage https://www.sciencebuddies.org/science-fair-projects/references/ascii-table
I think what I will try is to create a txt file with extended ascii mapping based on this webpage: https://theasciicode.com.ar/ Is there is a simpler programmatic way (eg with setlocale)?