From 96f6fc28b80768a220e973f31100c9af725020cf Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 16 May 2019 11:39:38 +0200 Subject: [PATCH] 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 --- src/api/baseapi.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index 61b38f8e..5311a17d 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -41,7 +41,6 @@ #include #endif // _WIN32 -#include // for LC_ALL, LC_CTYPE, LC_NUMERIC #include // for round, M_PI #include // for int32_t #include // for strcmp, strcpy @@ -209,13 +208,16 @@ TessBaseAPI::TessBaseAPI() rect_height_(0), image_width_(0), image_height_(0) { - const char *locale; - locale = std::setlocale(LC_ALL, nullptr); - ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8")); - locale = std::setlocale(LC_CTYPE, nullptr); - ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8")); - locale = std::setlocale(LC_NUMERIC, nullptr); - ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8")); +#if defined(DEBUG) + // The Tesseract executables would use the "C" locale by default, + // but other software which is linked against the Tesseract library + // typically uses the locale from the user's environment. + // Here the default is overridden to allow debugging of potential + // problems caused by the locale settings. + + // Use the current locale if building debug code. + std::locale::global(std::locale("")); +#endif } TessBaseAPI::~TessBaseAPI() {