How to solve the problem of accentuation in the terminal?

1

I'm writing some strings on the screen using the Opengl library and some of the stored words are accented words, for example: república checa , where the output ends up being: repblica checa can solve this problem without using external library? I would not like to use #include <locale> for fear of incompatibility between windows or linux systems, any solution?

One way of using the ASCII table is not a viable option.

    
asked by anonymous 30.04.2016 / 01:03

1 answer

3

Maybe std::wcout ( wchar_t ) solve your problem

#include <iostream>

int main() {
    std::wcout << L"república" << std::endl;
    return 0;
}

In windows to work according to this response in SOen it is necessary to start with cmd with /u

Another thing you can try in the case of Windows is to use _setmode as described here: link (this worked without needing to /u )

#include <fcntl.h>
#include <io.h>
#include <stdio.h>

int main(void) {
    _setmode(_fileno(stdout), _O_U16TEXT);
    wprintf(L"república\n");
    return 0;
}

Result:

  

I tested VisualStudio and Mingw

    
30.04.2016 / 01:27