I wrote:

> If you're interested only in golf, and don't care about those
> issues, you can eliminate several bytes easily:
> 
>     $str=~s/[^ -~]/sprintf'\%03o',ord$&/ge;

If hexadecimal escape codes are acceptable in place of octal,
you can save another 3 bytes:

      $str=~s/[^ -~]/'\x'.unpack H2,$&/ge;

Save 4 more bytes by using \c escapes, but that doesn't handle 
anything above 127, and I doubt PostgreSQL would like it 
anyway:

      $str=~s/[^ -~]/'\c'.($&^'@')/ge;


-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Washington, DC

Reply via email to