1-byte ASCII ?

Just starting out? Need help? Post your questions and find answers here.
epog10
User
User
Posts: 90
Joined: Sat May 29, 2010 11:46 am
Location: UK

1-byte ASCII ?

Post by epog10 »

I write to a file opened as:-
OpenFile(#DATNUM, "Name.dat", #PB_Ascii)
character by character using:-
WriteByte(#DATNUM, Asc(aCHAR))

I read it with:-
ReadFile(#DATNUM, "Name.dat", #PB_Ascii)
character by character using:-
aCHAR = Chr(ReadByte(#DATNUM))

Why am I not getting the high ASCIIs as single bytes below 255?

In the following short test extract the 'h' characters have been replaces with chr(209) which should be Ñ but this is how it reads back from the file:-
1 32
2 A 65
3 n 110
4 o 111
5 t 116
6 ￑ 65489
7 e 101
8 r 114
9 32
10 t 116
11 e 101
12 s 115
13 t 116
14 32
15 ￑ 65489
16 e 101
17 r 114
18 e 101
19 32

Regard,
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: 1-byte ASCII ?

Post by wilbert »

Use ReadAsciiCharacter instead of ReadByte.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: 1-byte ASCII ?

Post by NicTheQuick »

Byte is signed and Ascii is unsigned.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
epog10
User
User
Posts: 90
Joined: Sat May 29, 2010 11:46 am
Location: UK

Re: 1-byte ASCII ?

Post by epog10 »

Silly me!

Shows how rarely I use Purebasic!

Many thanks to both of you.
Post Reply