Beispiel #1
0
        /// <summary>
        /// Clone the <see cref="Base64Encoder"/> with its current state.
        /// </summary>
        /// <remarks>
        /// Creates a new <see cref="Base64Encoder"/> with exactly the same state as the current encoder.
        /// </remarks>
        /// <returns>A new <see cref="Base64Encoder"/> with identical state.</returns>
        public IMimeEncoder Clone()
        {
            var encoder = new Base64Encoder(rfc2047, quartetsPerLine * 4);

            encoder.quartets = quartets;
            encoder.saved1   = saved1;
            encoder.saved2   = saved2;
            encoder.saved    = saved;

            return(encoder);
        }
Beispiel #2
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 ("?=");
		}
Beispiel #3
0
		/// <summary>
		/// Clone the <see cref="Base64Encoder"/> with its current state.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="Base64Encoder"/> with exactly the same state as the current encoder.
		/// </remarks>
		/// <returns>A new <see cref="Base64Encoder"/> with identical state.</returns>
		public IMimeEncoder Clone ()
		{
			var encoder = new Base64Encoder (rfc2047, quartetsPerLine * 4);

			encoder.quartets = quartets;
			encoder.saved1 = saved1;
			encoder.saved2 = saved2;
			encoder.saved = saved;

			return encoder;
		}