1. --****************************************************************************
  2. -- Script:   NULL_ENCODER - PRegXtra Version
  3. -- Version:  0.1
  4. -- Date:     2006/08/28
  5. --
  6. -- inspired by Bill Brubaker
  7. --
  8. --****************************************************************************
  9.  
  10. ----------------------------------------
  11. -- str can be string or StringBufferList
  12. ----------------------------------------
  13. on null_encode_preg (str)
  14.  
  15.   if listP(str) then
  16.     SrchStrL = [str[1]] -- necessary because string length grows
  17.   else
  18.     SrchStrL = [str]
  19.   end if
  20.  
  21.   PRegEx_Replace(SrchStrL, "\x5c", "g", "\\|")
  22.   PRegEx_Replace(SrchStrL, "\x0D", "g", "\\-")
  23.   PRegEx_Replace(SrchStrL, "\x00", "g", "\\ ")
  24.  
  25.   if listP(str) then str[1] = SrchStrL[1] -- to enable pass by reference
  26.   return SrchStrL[1]
  27. end
  28.  
  29.  
  30. ----------------------------------------
  31. -- str can be string or StringBufferList
  32. ----------------------------------------
  33. on null_decode_preg (str)
  34.  
  35.   if listP(str) then
  36.     SrchStrL = [str[1]] -- necessary because string length grows
  37.   else
  38.     SrchStrL = [str]
  39.   end if
  40.  
  41.   PRegEx_ReplaceExec(SrchStrL, "\x5c(.)", "g", #_preg_callback)
  42.  
  43.   if listP(str) then str[1] = SrchStrL[1] -- to enable pass by reference
  44.   return SrchStrL[1]
  45. end
  46.  
  47. -- or can this be done without PRegEx_ReplaceExec and a callback ???
  48. on _preg_callback
  49.   return numtochar(chartonum(PRegEx_GetMatchString(1))-32)
  50. end
  51.  
[raw code]