PeekS() with #PB_Ascii flag in >=PB5.51

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Addict
Addict
Posts: 4996
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

PeekS() with #PB_Ascii flag in >=PB5.51

Post by Psychophanta »

Hi all,

since in PB >= 5.51 there is not possible to manage string variables as extended ascii format; what is the meaning of the function PeekS() used with the #PB_Ascii flag ?
Last edited by Psychophanta on Tue May 23, 2017 2:07 am, edited 1 time in total.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
skywalk
Addict
Addict
Posts: 3994
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PeekS() with @PB_Ascii flag in >=PB5.51

Post by skywalk »

We need this to scan memory that contains Ascii text, even though it is returned into a PB unicode string. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Psychophanta
Addict
Addict
Posts: 4996
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: PeekS() with #PB_Ascii flag in >=PB5.51

Post by Psychophanta »

Aha, that's it, and how do you scan a thing if the function does not say that it matches an ascii sequence?
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: PeekS() with #PB_Ascii flag in >=PB5.51

Post by Sicro »

Psychophanta wrote:how do you scan a thing if the function does not say that it matches an ascii sequence?
You can try reading the memory by using different string formats, and the string format that not results in garbage, is the right string format. Sure, this way is very bad.
The only right way is that the developer of the function documents the string format, that the function returns.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: PeekS() with #PB_Ascii flag in >=PB5.51

Post by walbus »

Ascii strings have never zero bytes inside
Ascii chars inside a Unicode strings have ever double zero pairs inside, for each character a pair

A PB based Ascii string ends with a zero byte
A PB based Unicode string ends with two zero bytes
This zero bytes are the string termination
Fixed strings (with a defined length) have not a termination

Saved text should have ever a BOM - Looking therefore in the Wikipedia and the PB Doku

Looking also for UTF-8
Post Reply