Skip to content

Commit

Permalink
Fix function tesseract::WriteFeature (issue #3925) (#3972)
Browse files Browse the repository at this point in the history
Fixes: 3b07599 ("Replace more STRING by std::string")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil authored Dec 3, 2022
1 parent c1a1d7e commit a529221
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/classify/ocrfeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <cassert>
#include <cmath>
#include <sstream> // for std::stringstream

namespace tesseract {

Expand Down Expand Up @@ -106,7 +107,13 @@ static void WriteFeature(FEATURE Feature, std::string &str) {
#ifndef WIN32
assert(!std::isnan(Feature->Params[i]));
#endif
str += " " + std::to_string(Feature->Params[i]);
std::stringstream stream;
// Use "C" locale (needed for double value).
stream.imbue(std::locale::classic());
// Use 8 digits for double value.
stream.precision(8);
stream << Feature->Params[i];
str += " " + stream.str();
}
str += "\n";
} /* WriteFeature */
Expand Down

0 comments on commit a529221

Please sign in to comment.