mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-03 00:49:01 +08:00
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>
This commit is contained in:
parent
77f9bad3c2
commit
331cc84d8d
@ -41,7 +41,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#include <clocale> // for LC_ALL, LC_CTYPE, LC_NUMERIC
|
|
||||||
#include <cmath> // for round, M_PI
|
#include <cmath> // for round, M_PI
|
||||||
#include <cstdint> // for int32_t
|
#include <cstdint> // for int32_t
|
||||||
#include <cstring> // for strcmp, strcpy
|
#include <cstring> // for strcmp, strcpy
|
||||||
@ -209,13 +208,16 @@ TessBaseAPI::TessBaseAPI()
|
|||||||
rect_height_(0),
|
rect_height_(0),
|
||||||
image_width_(0),
|
image_width_(0),
|
||||||
image_height_(0) {
|
image_height_(0) {
|
||||||
const char *locale;
|
#if defined(DEBUG)
|
||||||
locale = std::setlocale(LC_ALL, nullptr);
|
// The Tesseract executables would use the "C" locale by default,
|
||||||
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
|
// but other software which is linked against the Tesseract library
|
||||||
locale = std::setlocale(LC_CTYPE, nullptr);
|
// typically uses the locale from the user's environment.
|
||||||
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
|
// Here the default is overridden to allow debugging of potential
|
||||||
locale = std::setlocale(LC_NUMERIC, nullptr);
|
// problems caused by the locale settings.
|
||||||
ASSERT_HOST(!strcmp(locale, "C") || !strcmp(locale, "C.UTF-8"));
|
|
||||||
|
// Use the current locale if building debug code.
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TessBaseAPI::~TessBaseAPI() {
|
TessBaseAPI::~TessBaseAPI() {
|
||||||
|
Loading…
Reference in New Issue
Block a user