fgetchar returning wrong data
#1

I got a problem using fgetchar to get data from a binary file. The content of the file is (only for testing, the real one is bigger)
Код:
44 21 3c da be 00 0a ff
Now i'm trying to read every byte using fgetcar. The result is
Код:
44 21 3c 1be 00 0a ff ffffffff
0xFFFFFFFF is EOF, the error seems to happen at 0xDA since replacing it with certain other values works - but then again with other values it doesn't work. Has anyone experienced strange behavior of fgetchar? The return value should be either EOF (end of file) or [0;0xFF], yet 0x1BE (446) is being returned.

//Edit: colorization of some values
Reply
#2

The documentation of fgetchar is a bit vague, you need to use it like that with "0, false" to disable utf8 decoding
Quote:
Originally Posted by BigETI
Посмотреть сообщение
pawn Код:
#define freadchar(%0) fgetchar(%0, 0, false)
#define fwritechar(%0,%1) fputchar(%0,(%1)&0xFF, false)
Just quoted this from his topic "Binary file I/O in PAWN"
Reply
#3

Oh, that's really strange. I disabled utf8 decoding by using fgetchar(handle, false) because https://sampwiki.blast.hk/wiki/Fgetchar says that it uses 2 parameters and the second one toggles the utf8 decoding. Having a look into the files.inc I realized it has 3 parameters. Well, thank you very much What does the parameter "value" mean btw?
Reply
#4

I have no clue, also it doesn't affect anything
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)