MimeKit.Header.EncodeReferencesHeader C# (CSharp) Method

EncodeReferencesHeader() static private method

static private EncodeReferencesHeader ( ParserOptions options, MimeKit.FormatOptions format, Portable.Text.Encoding charset, string field, string value ) : byte[]
options ParserOptions
format MimeKit.FormatOptions
charset Portable.Text.Encoding
field string
value string
return byte[]
		static byte[] EncodeReferencesHeader (ParserOptions options, FormatOptions format, Encoding charset, string field, string value)
		{
			var encoded = new StringBuilder ();
			int lineLength = field.Length + 1;
			int count = 0;

			foreach (var reference in MimeUtils.EnumerateReferences (value)) {
				if (count > 0 && lineLength + reference.Length + 3 > format.MaxLineLength) {
					encoded.Append (format.NewLine);
					encoded.Append ('\t');
					lineLength = 1;
					count = 0;
				} else {
					encoded.Append (' ');
					lineLength++;
				}

				encoded.Append ('<').Append (reference).Append ('>');
				lineLength += reference.Length + 2;
				count++;
			}

			encoded.Append (format.NewLine);

			return charset.GetBytes (encoded.ToString ());
		}