The following example shows how to detect the encoding of the document:
// Create an instance of LoadOptions class with the default ANSI encoding.// This encoding is returned for ANSI text documents.LoadOptionsloadOptions=newLoadOptions(FileFormat.WordProcessing,null,null,Encoding.GetEncoding(1251));// Create an instance of Parser classusing(Parserparser=newParser(Constants.SampleText,loadOptions)){// Get the document infoTextDocumentInfoinfo=parser.GetDocumentInfo()asTextDocumentInfo;// Check if it's the document info of a plain text documentif(info==null){Console.WriteLine("Isn't a plain text document");return;}// Print the encodingConsole.WriteLine("Encoding: "+info.Encoding.WebName);}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.