예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MimeKit.Encodings.QEncoder" /> class.
 /// </summary>
 /// <remarks>
 /// Creates a new rfc2047 quoted-printable encoder.
 /// </remarks>
 /// <param name="mode">The rfc2047 encoding mode.</param>
 public QEncoder(QEncodeMode mode)
 {
     mask = ((mode == QEncodeMode.Phrase) ? CharType.IsEncodedPhraseSafe : CharType.IsEncodedWordSafe);
 }
예제 #2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MimeKit.Encodings.QEncoder"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new rfc2047 quoted-printable encoder.
		/// </remarks>
		/// <param name="mode">The rfc2047 encoding mode.</param>
		public QEncoder (QEncodeMode mode)
		{
			mask = mode == QEncodeMode.Phrase ? CharType.IsEncodedPhraseSafe : CharType.IsEncodedWordSafe;
		}
예제 #3
0
		static void AppendEncodedWord (StringBuilder str, Encoding charset, string text, int startIndex, int length, QEncodeMode mode)
		{
			var chars = new char[length];
			IMimeEncoder encoder;
			byte[] word, encoded;
			char encoding;
			int len;

			text.CopyTo (startIndex, chars, 0, length);

			try {
				word = CharsetConvert (charset, chars, length, out len);
			} catch {
				charset = Encoding.UTF8;
				word = CharsetConvert (charset, chars, length, out len);
			}

			if (CharsetRequiresBase64 (charset) || GetBestContentEncoding (word, 0, len) == ContentEncoding.Base64) {
				encoder = new Base64Encoder (true);
				encoding = 'b';
			} else {
				encoder = new QEncoder (mode);
				encoding = 'q';
			}

			encoded = new byte[encoder.EstimateOutputLength (len)];
			len = encoder.Flush (word, 0, len, encoded);

			str.AppendFormat ("=?{0}?{1}?", CharsetUtils.GetMimeCharset (charset), encoding);
			for (int i = 0; i < len; i++)
				str.Append ((char) encoded[i]);
			str.Append ("?=");
		}
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MimeKit.Encodings.QEncoder"/> class.
 /// </summary>
 /// <remarks>
 /// Creates a new rfc2047 quoted-printable encoder.
 /// </remarks>
 /// <param name="mode">The rfc2047 encoding mode.</param>
 public QEncoder(QEncodeMode mode)
 {
     mask = mode == QEncodeMode.Phrase ? CharType.IsEncodedPhraseSafe : CharType.IsEncodedWordSafe;
     Reset();
 }