Skip to content

Commit 331cc84

Browse files
committed
Remove assertions for unsupported locale settings
The latest code passed all unittests with locale de_DE.UTF-8 and has fixed the locale issues which were reported on GitHub. Therefore the assertions can be removed. Any remaining locale issue will be fixed when it is identified. To help finding such remaining isses, debug code now uses the user's locale settings instead of the default "C" locale for all executables which use TessBaseAPI. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 77f9bad commit 331cc84

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/api/baseapi.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <unistd.h>
4242
#endif // _WIN32
4343

44-
#include <clocale> // for LC_ALL, LC_CTYPE, LC_NUMERIC
4544
#include <cmath> // for round, M_PI
4645
#include <cstdint> // for int32_t
4746
#include <cstring> // for strcmp, strcpy
@@ -209,13 +208,16 @@ TessBaseAPI::TessBaseAPI()
209208
rect_height_(0),
210209
image_width_(0),
211210
image_height_(0) {
212-
const char *locale;
213-
locale = std::setlocale(LC_ALL, nullptr);
214-
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
215-
locale = std::setlocale(LC_CTYPE, nullptr);
216-
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
217-
locale = std::setlocale(LC_NUMERIC, nullptr);
218-
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
211+
#if defined(DEBUG)
212+
// The Tesseract executables would use the "C" locale by default,
213+
// but other software which is linked against the Tesseract library
214+
// typically uses the locale from the user's environment.
215+
// Here the default is overridden to allow debugging of potential
216+
// problems caused by the locale settings.
217+
218+
// Use the current locale if building debug code.
219+
std::locale::global(std::locale(""));
220+
#endif
219221
}
220222

221223
TessBaseAPI::~TessBaseAPI() {

0 commit comments

Comments
 (0)