Tag: fiorenza

StrEscape, StrQuoteMeta From PHP to PB. (quotemeta, addslashes)

Posted by on June 11, 2008

If you’re used to PHP, you might of know the functions ‘quotemeta();’ and ‘addslashes();’ are very, very useful when dealing with user Input and similar activities where escaping certain entities (characters!) is very important.

This routines, while not too elegant, do the same (or similar) job as PHP but in PB:

The equivalent to quotemeta(); in PHP can be found in here.
Whereas the addslashes(); counterpart is located in here.
(I know, the PHP lexer I’m using has a bug on the PB definition, I’ll take a look later).

Ascii helper routines, part 1

Posted by on June 11, 2008

Whenever I have to manipulate strings in PB, on a low-level (ie. per-character basis) I find it almost imperative to have the following routines included in my project:

 is_alpha(); is_numeric(); is_symbol();

They are amongst the most basic routines out there, however, they are still useful nonetheless.

You can grab the include/source from here: http://gushh.net/dev/?file=pb/ascii_helpers.pb

If you’re working on a Lexer, Parser, or similar… this will come in handy in case you don’t have it already.

Cheers.