How to make my code read in UTF-8 in C?

Asked

Viewed 2,210 times

3

When I spin that code:

#include <stdio.h>

int main(void) {
  int teste[10];
  printf("Imprimindo o vetor 'teste': %d\n", teste);
  printf("O endereço do primeiro elemento é: %d\n", teste[0]);

  return 0;
}

The letters "is" and "ç" come out with these strange symbols:inserir a descrição da imagem aqui

How to get these letters read by the program with UTF-8 encoding?

  • I guess that answers, doesn’t it? https://answall.com/q/137043/101

  • 2
  • 2

    The setlocale (LC_ALL, "portuguese"); and its IDE configuration

  • I disagree that it is duplicate. The other question is about compilation problems because some characters have more than one byte. On this deck, whether or not a character is represented in a byte has little importance. Also, I can’t see how the @Maniero response from there can solve the problem from here, it just explains a little more about encoding problems that exist here.

1 answer

2


You can put the ASCII code directly into the printf or vc can add the locale library. h and add the setlocale line (LC_ALL, ""); at the beginning of the code

Browser other questions tagged

You are not signed in. Login or sign up in order to post.