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.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Cookie Notice
Language
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.