How can I accentuate words in Fortran and print to the screen without errors?

Viewed 67

In C, when we want to print an accented word, as in the Portuguese language, we use the library locale.h and the command setlocale(LC_ALL, "Portuguese") so that the output is printed on the screen correctly. As an example, I present the following code:

#include <stdio.h>
#include <locale.h>

int main()
{
    setlocale(LC_ALL, "Portuguese");
    printf("\n\tA maçã caiu na cebeça dele! É a gravidade.\n");
    return 0;
}

returning the following message:

A maça caiu na cebeça dele! É a gravidade.

Process returned 0 (0x0)   execution time : 0.350 s
Press any key to continue.

On the other hand, when I do the same for Fortran, i.e.,

program hello
    implicit none
    
    print *, "A maçã caiu na cebeça dele! É a gravidade."

end program

I obtain:

 A maτπ caiu na cebeτa dele! ╔ a gravidade.

Process returned 0 (0x0)   execution time : 1.206 s
Press any key to continue.

This occurs because, unlike C, I don't know a mechanism for Fortran like the one provided by the locale.h library in the C language.

Given this, I ask: How can I do the analog treatment in Fortran? Is this possible?

Remark: I am using MSYS2 MinGW64 (gfortran) on Windows with Code::Blocks and CLion (plugin Fortran).

0 Answers
Related