It is currently Tue Aug 20, 2019 9:18 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: 1-byte ASCII ?
PostPosted: Mon Jul 01, 2019 1:45 pm 
Offline
User
User

Joined: Sat May 29, 2010 11:46 am
Posts: 79
Location: UK
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,


Top
 Profile  
Reply with quote  
 Post subject: Re: 1-byte ASCII ?
PostPosted: Mon Jul 01, 2019 2:10 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3374
Location: Netherlands
Use ReadAsciiCharacter instead of ReadByte.

_________________
macOS 10.14 Mojave, PB 5.62 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: 1-byte ASCII ?
PostPosted: Mon Jul 01, 2019 2:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 416
Location: Germany, Saarbrücken
Byte is signed and Ascii is unsigned.

_________________
Electronics, Crazy & Interesting Stuff, all that with text, image and sound? Click here!

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: 1-byte ASCII ?
PostPosted: Mon Jul 01, 2019 3:24 pm 
Offline
User
User

Joined: Sat May 29, 2010 11:46 am
Posts: 79
Location: UK
Silly me!

Shows how rarely I use Purebasic!

Many thanks to both of you.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye