Skip to main content
GameDev.net gamedev.net
🔒 Locked

Ascii code problems

Started by Damien Oct 23, 2000 at 12:55 PM 4 replies 400+ views
Original Post
Damien
Damien
When I right the character ''À'' to a file its ascii code is 192, but when i read it in I get -64 as the ascii code, can someone explain this to me, No doubt its something small or a misunderstanding on my part but i''m a little confused now. Thanks in Advance
SiCrane
SiCrane
You''re probably using a char to read in the value. Try using instead an unsigned char.
phueppl1
phueppl1
Could it be that you''re using a signed char instead of an unsigned char? I think this happens cause as soon as it gets higher than 128 it get''s to the bit that decides if it''s signed or unsigned and that causes the value to be negative...
hope that helped!
cya,
Phil


Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states ;)
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
phueppl1
phueppl1
ah, he was faster ;o)
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
Damien
Damien
I using a Fstream and a string

Fstream fsInputFile;
string str;
fsInputFile.open("filename.txt",ios:in);

fsInputfile >> str;

can I use this or do I have to switch to usigned char
SiCrane
SiCrane
An fstream is a typedef''d basic_fstream with type char. If instead you use a basic_fstream >, you should be able to get non-negative values for all characters read.

i.e.

You''re using:
typedef basic_fstream > fstream;

try
typedef basic_fstream > my_fstream;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.