Click or drag to resize
MimeKit

TextPartTryDetectEncoding Method

Try to detect the encoding of the text content.

Namespace: MimeKit
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public bool TryDetectEncoding(
	out Encoding encoding,
	out TextEncodingConfidence confidence
)

Parameters

encoding  Encoding
The detected encoding; otherwise, null.
confidence  TextEncodingConfidence
The confidence in the detected encoding being correct.

Return Value

Boolean
true if an encoding was detected; otherwise, false.
Exceptions
ExceptionCondition
ObjectDisposedException The TextPart has been disposed.
Remarks

Attempts to detect the encoding of the text content.

If no content is defined, then encoding is set to ASCII and confidence is set to Irrelevant.

If a charset is specified on the Content-Type header and it is a supported encoding, then encoding is set to the encoding for the specified charset and confidence is set to Certain.

If a Byte-Order-Mark (BOM) is found, then encoding is set to the corresponding unicode encoding and confidence is set to Certain.

If the content is in HTML format, then the first 1024 bytes are processed for <meta> tags containing charset information. If charset information is found and the charset is a supported encoding, then encoding is set to the encoding for the specified charset and confidence is set to Tentative.

See Also