I kinda like MIME's choice. XML's CDATA seems rather pointless to me, by contrast (having such a strange syntax that still requires one to escape a 3-char delimiter but whose existance is "justified" because you don't have to escape a 1-char delimiter).

For MIME, you pick some short, random string (from a restricted set of characters). If that string is in the data to be sent, then look at the character that follows it and append some other random character on the end of your random string. Repeat until you have a string that does not appear anywhere in your data. Then output the delimiter before and after the data. It requires that you scan the data to be sent once before you send it but is robust in the face of character translations in your pipe (important in an e-mail protocol where trailing spaces might not be preserved, for example) and doesn't require any transformation of the data to be sent.

- tye        


In reply to Re^2: How to end socket file transfer without closing socket (MIME) by tye
in thread How to end socket file transfer without closing socket by redss

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.