in reply to uuencoding to deal with line breaks

Try URL encoding the body instead of uuencoding it.

You can use CGI::encode(), or roll your own via

  ($encoded = $body) =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
  • Comment on Re: uuencoding to deal with line breaks

Replies are listed 'Best First'.
Re: Re: uuencoding to deal with line breaks
by epoptai (Curate) on Dec 16, 2000 at 06:11 UTC
    Thanks dws. I like that uu can't be casually read and is a bit smaller than url encoded output. I didn't know about CGI::Encode.

    I tired ichimunki's suggestion but ended up with line breaks in the file. That's what i was trying before resorting to uu. I'm being used by windows if that makes a difference.

    IO has me stumped. I tried a few 45s short of 45k or 45megs and noticed nothing strange. But i'm hoping it never throws a | in there :-)

    45?

      $encoded_body = pack "u", $body="\n"x46 will contain "\n", If you were worried about "\n" in $body, what about "\n" in $encoded_body?
        Rarely there's an \N in $encoded_body (it's all uppercase) but it doesn't cause a problem, and $encoded_body=~s/\n//g; doesn't touch it.