skip to Main Content

i am coding in C.
i have code runner and c extension.

#include <stdio.h>

int main() {
    printf("500 ₱n");
    return 0;
}

this will output in the terminal: 500 ₱

I checked and these are my fonts in vscode text editor: Consolas, ‘Courier New’, monospace
I also checked and it says i am on UTF-8 on encoding in files in vscode text editor.

I do not know what the problem is.

2

Answers


  1. Change encoding of your terminal. The output seems to be a correct UTF-8, but interpreted as CP437 (MS-DOS encoding). For example on Windows use in terminal command chcp 65001 to switch to UTF-8.

    U+20B1 ₱ PESO SIGN, encoded in UTF-8 becomes bytes 0xE2 0x82 0xB1.

    If you look at CP437 chart, E2 is Γ, 82 is é, and B1 is ▒. Your code is correct, just terminal is not set to UTF-8.

    Login or Signup to reply.
  2. Have you tried this in a different window? That way you can rule out the code being bad.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search