officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-417d3c51.md
Occurs before detection of the loaded plain text or HTML encoding.
Namespace : DevExpress.XtraRichEdit
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
public event EventHandler<BeforeEncodingDetectionEventArgs> BeforeEncodingDetection
Public Event BeforeEncodingDetection As EventHandler(Of BeforeEncodingDetectionEventArgs)
The BeforeEncodingDetection event's data class is BeforeEncodingDetectionEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Encoding | Gets or sets the document encoding. |
| Handled | Gets or sets whether the event is handled. |
| Stream | Obtains a stream with document data. |
The BeforeEncodingDetection event is raised when the RichEditDocumentServer attempts to detect encoding of the plain text or HTML text being imported. Handle this event to specify a custom encoding instead of the detected encoding.
The event fires only if the PlainTextDocumentImporterOptions.AutoDetectEncoding or HtmlDocumentImporterOptions.AutoDetectEncoding property is set to true.
private void RichEditDocumentServer_BeforeEncodingDetection(object? sender, BeforeEncodingDetectionEventArgs e)
{
e.Encoding = Encoding.UTF8;
e.Handled = true;
}
Private Sub RichEditDocumentServer_BeforeEncodingDetection(ByVal sender As Object, ByVal e As BeforeEncodingDetectionEventArgs)
e.Encoding = Encoding.UTF8
e.Handled = True
End Sub
See Also