public TesseractEngine(string dataPath, string language, EngineMode engineMode)
        {
            if (dataPath == null)
            {
                throw new ArgumentNullException(nameof(dataPath));
            }

            if (dataPath == string.Empty)
            {
                throw new ArgumentException("Data path is empty.", nameof(dataPath));
            }

            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            dataPath = dataPath.Trim();
            if (dataPath.EndsWith("\\", StringComparison.Ordinal) || dataPath.EndsWith("/", StringComparison.Ordinal))
            {
                dataPath = dataPath.Substring(0, dataPath.Length - 1);
            }

            _handle = new HandleRef(this, Tesseract4.TessBaseAPICreate());
            if (Tesseract4.TessBaseAPIInit2(_handle, dataPath, language, (int)engineMode) == 0)
            {
                return;
            }

            _handle = new HandleRef(this, IntPtr.Zero);
            GC.SuppressFinalize(this);

            throw new TesseractException("Failed to initialise tesseract engine.");
        }
        public TesseractEngine(string dataPath, string language, EngineMode engineMode)
        {
            if (dataPath == null)
            {
                throw new ArgumentNullException(nameof(dataPath));
            }

            if (dataPath == string.Empty)
            {
                throw new ArgumentException("Data path is empty.", nameof(dataPath));
            }

            if (language == null)
            {
                throw new ArgumentNullException(nameof(language));
            }

            dataPath = dataPath.Trim();
            if (dataPath.EndsWith("\\", StringComparison.Ordinal) || dataPath.EndsWith("/", StringComparison.Ordinal))
            {
                dataPath = dataPath.Substring(0, dataPath.Length - 1);
            }

            if (!Directory.Exists(dataPath))
            {
                if (Debugger.IsAttached)
                {
                    dataPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? Directory.GetCurrentDirectory(), dataPath);
                }
                else
                {
                    throw new TesseractException($"Tesseract data path does not exists. Current directory: {Directory.GetCurrentDirectory()}. Supplied data path: {dataPath}.");
                }
            }

            _handle = new HandleRef(this, Tesseract4.TessBaseAPICreate());
            if (Tesseract4.TessBaseAPIInit2(_handle, dataPath, language, (int)engineMode) == 0)
            {
                return;
            }

            _handle = new HandleRef(this, IntPtr.Zero);
            GC.SuppressFinalize(this);

            throw new TesseractException("Failed to initialise tesseract engine.");
        }