mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-12 07:29:07 +08:00
Test for correct locale settings
Normal C++ programs like those which are built for tesseract automatically set the locale "C". There can be different locale settings if the tesseract library is used in other software. A wrong locale can cause wrong results from sscanf which is used at different places in the tesseract code, so make sure that we have the right locale settings and fail if that is not the case. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
a6623065fe
commit
3292484f67
@ -43,6 +43,7 @@
|
||||
#endif // _WIN32
|
||||
|
||||
#include <algorithm>
|
||||
#include <clocale>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
@ -185,7 +186,15 @@ TessBaseAPI::TessBaseAPI()
|
||||
rect_width_(0),
|
||||
rect_height_(0),
|
||||
image_width_(0),
|
||||
image_height_(0) {}
|
||||
image_height_(0) {
|
||||
const char *locale;
|
||||
locale = std::setlocale(LC_ALL, nullptr);
|
||||
ASSERT_HOST(!strcmp(locale, "C"));
|
||||
locale = std::setlocale(LC_CTYPE, nullptr);
|
||||
ASSERT_HOST(!strcmp(locale, "C"));
|
||||
locale = std::setlocale(LC_NUMERIC, nullptr);
|
||||
ASSERT_HOST(!strcmp(locale, "C"));
|
||||
}
|
||||
|
||||
TessBaseAPI::~TessBaseAPI() {
|
||||
End();
|
||||
|
Loading…
Reference in New Issue
Block a user