M
M
Murad Murtuzaliev2020-05-10 22:30:19
C++ / C#
Murad Murtuzaliev, 2020-05-10 22:30:19

Why is the character not displayed after conversion?

After converting a wchar_t character to wstring, the output sometimes displays some other characters, sometimes nothing at all. What could be the problem?

#include <iostream>
#include <locale>
#include <codecvt>

int main() {
    setlocale(LC_ALL, "");
    wchar_t character = L'Е';
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    std::wstring wcharacter = converter.from_bytes(character);
    std::wcout << wcharacter << std::endl;
    return 0;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question