Convert Text to Canonical Form
Data within a MIME message should always be converted to the format defined by MIME for that datatype, the canonical form (see Canonical Form ). For most data formats, the canonical form is identical to the normal format of the data.
One common case where the canonical form may not be identical to the normal data format is text. For text, the canonical form represents a line break as a carriage return (ASCII 13) followed by a line feed (ASCII 10). RWMimeUtils provides a static replaceLineDelim() function for translating text to and from canonical form. When provided with only an RWCString as an argument, the function returns a copy of the string converted to canonical form. To convert text to canonical form:
 
RWCString text;
 
// ... fill the RWCString with text in a platform-specific format
 
RWCString canonText = RWMimeUtils::replaceLineDelim(text);
When a second argument is provided, the function translates each line break in the original string to the character sequence in the second argument. For example, UNIX platforms use a single newline character for a line break. To translate the line breaks in a canonical form string to UNIX line breaks, provide a newline as the second argument to replaceLineDelim(), as shown in the following code:
 
RWCString canonText;
 
// ... fill the RWCString with text in canonical form
 
RWCString text = RWMimeUtils::replaceLineDelim(canonText, "\n");