[pmwiki-users] Misc Questions on FAST Data...

Patrick R. Michaud pmichaud at pobox.com
Mon Sep 11 12:32:42 CDT 2006


On Mon, Sep 11, 2006 at 11:38:17AM -0400, The Editor wrote:
> I'm doing some rewrite of FAST Data to add various new features and
> fix a few small bugs.  Here are a couple initial (simple?) questions I
> could not seem to solve, and would appreciate some help with.
> 
> 1) Format used for WritePage().
> I'm trying to use writepage to save the data, (instead of my own
> getpage/setpage functions, which use fread/fwrite) and have it near
> working with these lines:
> 
> 	$page = ReadPage($d);
> 	$page['text'] = $contents;
> 	Lock(2);
> 	WritePage($d, $page);
> 	Lock(0);
> 
> The problem is $contents is already encoded with things like %0a,
> etc., just like it looks when it is already saved.  So when I view
> the page I see the raw text string, not what I want.  What kind of
> formatting should I use when I create $contents?  

None.  ReadPage and WritePage are written such that whatever
you save with WritePage is exactly what you get back with ReadPage
(with the exception of certain values such as 'name', 'time', 'rev',
etc.).

> Can I use \n for line breaks? 

Yes.  WritePage will automatically convert the linefeeds to %0a,
and ReadPage will automatically convert them back to linefeeds.

> 2) How do I return a single line break?

If you mean a markup line break, then use "[[<<]]".

If you're wanting an end-of-line markup break, then use "\\\\",
which will end up being saved as two backslashes.  (The \ has
a special meaning to PHP, so two are required.)

> 3) I still have the problem of various characters like -'- being
> return -/'- when they are displayed, and not sure how to fix it.  

It's not a problem with the way you're saving or retrieving
the characters; it has to be a problem with the way the markup 
rule is handling them (look for rules with /e flags at the end).

Either that or it's a problem with data coming from a form,
in which case you need to run stripmagic(...) on the form
values before using them.

Pm




More information about the pmwiki-users mailing list