--****************************************************************************
-- Script: NULL_ENCODER - PRegXtra Version
-- Version: 0.1
-- Date: 2006/08/28
--
-- inspired by Bill Brubaker
--
--****************************************************************************
----------------------------------------
-- str can be string or StringBufferList
----------------------------------------
on null_encode_preg (str)
if listP(str) then
SrchStrL = [str[1]] -- necessary because string length grows
else
SrchStrL = [str]
end if
PRegEx_Replace(SrchStrL, "\x5c", "g", "\\|")
PRegEx_Replace(SrchStrL, "\x0D", "g", "\\-")
PRegEx_Replace(SrchStrL, "\x00", "g", "\\ ")
if listP(str) then str[1] = SrchStrL[1] -- to enable pass by reference
return SrchStrL[1]
end
----------------------------------------
-- str can be string or StringBufferList
----------------------------------------
on null_decode_preg (str)
if listP(str) then
SrchStrL = [str[1]] -- necessary because string length grows
else
SrchStrL = [str]
end if
PRegEx_ReplaceExec(SrchStrL, "\x5c(.)", "g", #_preg_callback)
if listP(str) then str[1] = SrchStrL[1] -- to enable pass by reference
return SrchStrL[1]
end
-- or can this be done without PRegEx_ReplaceExec and a callback ???
on _preg_callback
return numtochar(chartonum(PRegEx_GetMatchString(1))-32)
end