Console output of unsigned chars (initialized by hex) gives cyrillic output

Hi,

please, help to understand.

PROBLEM:I make the output with cout of unsigned chars, that are initialized as hex and receive ciryllic symbols on output with cout.
As I understand 0x63 is hex ASCII code of char 'c'; But I see cyrillic symbol 'я' instead... I don`t understand why!!!


CODE:

unsigned char Ar[2]={0x63,0x63};
cout << Ar[0]<<' '<< Ar[1]<< endl;


OUTPUT:
я я

SHOULD BE: c c




Now insert your code snip in the simple program and test it

1
2
3
4
5
6
7
#include <iostream>

int main()
{
   unsigned char Ar[2]={0x63,0x63};
   std::cout << Ar[0]<<' '<< Ar[1]<< std::endl;
}


For example you can test the code online at www.ideone.com
Last edited on
It works....
I will try on my compiler and will post the result here...
Last edited on
It looks like the problem is in somewhere else. The code snip you showed is irrelevant.
And what about this...(((


#include <iostream>
int main()
{
unsigned char Ar[2] ={0x7c,0xf2};
std::cout << Ar[0]<<' '<< Ar[1]<< std::endl;
}

OUTPUT: | �

What is a problem here...
Looks correct to me, 0x7c is the ascii code of |, and 0xf2 is invalid, which is correctly rendered as the replacement character �
0xf2 is ASCII code of '/'
I think you mean 0x2f is the ASCII code of '/'.
Last edited on
Thank You, Guys,

I thought, that hex will be outputted as chars latin symbols...from A-to z...
I looked through the ASCII table and understood my mistake.... that number of symbols in ASCII table are more than the number of only alphabetical chars)))

Thank You!

Topic archived. No new replies allowed.