Skip to content

Commit

Permalink
fix issue 1197
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1100 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
zdenop committed May 11, 2014
1 parent 2e520f2 commit 6051e40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,11 @@ char* TessBaseAPI::GetHOCRText(int page_number) {

hocr_str.add_str_int(" <div class='ocr_page' id='page_", page_id);
hocr_str += "' title='image \"";
hocr_str += input_file_ ? HOcrEscape(input_file_->string()) : "unknown";
if (input_file_) {
HOcrEscape(input_file_->string(), hocr_str);
} else {
hocr_str += "unknown";
}
hocr_str.add_str_int("\"; bbox ", rect_left_);
hocr_str.add_str_int(" ", rect_top_);
hocr_str.add_str_int(" ", rect_width_);
Expand Down Expand Up @@ -1443,7 +1447,7 @@ char* TessBaseAPI::GetHOCRText(int page_number) {
const char *grapheme = res_it->GetUTF8Text(RIL_SYMBOL);
if (grapheme && grapheme[0] != 0) {
if (grapheme[1] == 0) {
hocr_str += HOcrEscape(grapheme);
HOcrEscape(grapheme, hocr_str);
} else {
hocr_str += grapheme;
}
Expand Down Expand Up @@ -2568,9 +2572,8 @@ TessResultRenderer* TessBaseAPI::NewRenderer() {
}

/** Escape a char string - remove <>&"' with HTML codes. */
const char* HOcrEscape(const char* text) {
const void HOcrEscape(const char* text, STRING& ret) {
const char *ptr;
STRING ret;
for (ptr = text; *ptr; ptr++) {
switch (*ptr) {
case '<': ret += "&lt;"; break;
Expand All @@ -2581,6 +2584,5 @@ const char* HOcrEscape(const char* text) {
default: ret += *ptr;
}
}
return ret.string();
}
} // namespace tesseract.
2 changes: 1 addition & 1 deletion api/baseapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ class TESS_API TessBaseAPI {
}; // class TessBaseAPI.

/** Escape a char string - remove &<>"' with HTML codes. */
const char* HOcrEscape(const char* text);
const void HOcrEscape(const char* text, STRING& ret);
} // namespace tesseract.

#endif // TESSERACT_API_BASEAPI_H__

0 comments on commit 6051e40

Please sign in to comment.