<p>You might want to read my paper <a href="https://arxiv.org/abs/1801.07779" rel="nofollow noreferrer">The WiLI benchmark dataset for written language identification</a> and try <a href="https://github.com/MartinThoma/lidtk" rel="nofollow noreferrer"><code>lidtk</code></a>.</p>

<p>TL;DR: Give CLD-2 a try.</p>
language detection
<p>I am using <a href="http://code.google.com/p/tesseract-ocr/" rel="nofollow noreferrer">tesseract</a> for OCR, mainly on invoices. However, tesseract requires to specify the language before it starts processing a file. </p>

<p>I thought I am going to perform ocr based on a predefined default language. Then I'd like use the resulting text to check which language is used. If it is not the default language, I process it again in order to get a better result from tesseract. </p>

<p>But how can I implement a language detection algorithm? Is there a C++ library I could use?</p>