[OPEN-ILS-DEV] messagecatalog -- linefeeds and other escaped characters

Mike Rylander mrylander at gmail.com
Sat Aug 18 10:50:25 EDT 2007


On 8/18/07, Scott McKellar <mck9 at swbell.net> wrote:
>
> --- Mike Rylander <mrylander at gmail.com> wrote:
>
> > On 8/17/07, Dan Scott <denials at gmail.com> wrote:
>
> <snip>
>
> > > This is mostly a heads-up. I am mostly hoping that there's an
> > > existing XUL method I can call to handle the escaped characters. :)
> > >
> >
> > Agreed on the need, though I'll be surprised if that method isn't
> > spelled 'replace'. ;)
>
> I assume that you are proposing to use some utility function to
> replaces all occurrences of "\n" with linefeeds, all occurrences of
> "\t" with horizontal tabs, and so forth.
>
> While this approach will get the right answer most of the time, and
> maybe all of the time in practice, it will not always work in general.
>
[snip example]
>
> To do the job correctly, there's no way to avoid traversing the string
> character by character, responding to backslashes as you find them
> (unless of course such a function is already available).

Well, that's not entirely true.  The only real problem with doing this
via regexp in JS is that there is no zero-width negative look-behind
assertion in the JS regexp engine.  I've been looking at different
ways to mimic that, but they all fall down in some areas.  I haven't
yet concluded if those failures are of any consequence to us, though.

Of course, now, after a couple cups of coffee and a few hours of
sleep, it seems like it may be easiest just to port the portion of the
C function that does this for JSON parsing ...

Thanks for the perspective, Scott.  And I haven't forgotten your
patch, I just haven't had a chance to test it yet!

-- 
Mike Rylander
Equinox Software, Inc
miker at esilibrary.com
http://esilibrary.com/


More information about the Open-ils-dev mailing list