Sets the text from a Unicode string, with a charset hint.
This convenience method sets the content of the Text
object from a Unicode string. The method converts the Unicode
characters to the specified character encoding (charset), then
creates and adds encoded words using either the B transfer encoding
(base64) or Q transfer encoding (a modified form of
quoted-printable).
As a special case, if all the characters in the string have code points less than 128 (that is, ASCII characters), then the library adds the string unchanged and does not create encoded words.
The library uses the capability of the .NET framework library
to perform character set conversions and encodings. Therefore,
the supported character encodings are those that are supported by
the .NET framework. The method throws a NotSupportedException
exception if the specified charset is not supported or recognized.
Since the UTF-8 charset is always available, you should consider
using UTF-8 as a fallback charset for any charset that is not
supported.
The library uses the Q transfer encoding for all 8-bit character sets, and the B transfer encoding for all multi-byte character encodings. There are two exceptions: If the charset is UTF-8, then the library chooses between the Q and B transfer encodings, whichever yields the shortest length. If the charset is UTF-7, then the library uses the Q encoding.
This method sets the is-modified flag.
References:RFC 2047 describes the encoding of unstructured text using encoded words. The book Developing International Software, Second Edition by Dr. International, published by Microsoft Press, is a good reference for understanding the character encoding capability of the .NET framework. Good online information is available from Microsoft's GlobalDev web site.
| Exception Type | Condition |
|---|---|
| NotSupportedException | charset is not recognized or supported.
|
Text Class | Hunny.Mime Namespace