skip to Main Content

I am working on a project using the characters and . Currently, I have code that looks like this:

const char dark = 0xB2;
const char light = 0xB0;
cout << dark;
cout << light;

This code works perfectly fine and outputs the correct characters on my laptop and my alternate desktop, but on my main desktop this code outputs the characters instead of the light shade and instead of the dark shade.

I assume I am using the wrong character set or other setting in Visual Studio somehow, but this is a fresh install and I haven’t touched anything like that, and like I said it works fine on my two other PCs.

2

Answers


  1. Chosen as BEST ANSWER

    The character encoding for my pc was incorrect. I did this and it fixed the issue: https://scholarslab.github.io/learn-twarc/08-win-region-settings


  2. You are using char values that are outside of the basic ASCII set (0-127), so their interpretation and display are very much dependent on the particular charset which the console is configured to use.

    For instance, the IBM850 charset (codepage 850) has the characters you are interested in, whereas charset JIS_X0201 (codepage 50222) outputs the other characters you mention for the same char values.

    If you need to use a specific charset for your output, try using SetConsoleOutputCP().

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