MCPcopy Create free account
hub / github.com/creatale/node-dv / GetUTF8Text

Method GetUTF8Text

deps/tesseract/ccmain/resultiterator.cpp:556–597  ·  view source on GitHub ↗

* Returns the null terminated UTF-8 encoded text string for the current * object at the given level. Use delete [] to free after use. */

Source from the content-addressed store, hash-verified

554 * object at the given level. Use delete [] to free after use.
555 */
556char* ResultIterator::GetUTF8Text(PageIteratorLevel level) const {
557 if (it_->word() == NULL) return NULL; // Already at the end!
558 STRING text;
559 switch (level) {
560 case RIL_BLOCK:
561 {
562 ResultIterator pp(*this);
563 do {
564 pp.AppendUTF8ParagraphText(&text);
565 } while (pp.Next(RIL_PARA) && pp.it_->block() == it_->block());
566 }
567 break;
568 case RIL_PARA:
569 AppendUTF8ParagraphText(&text);
570 break;
571 case RIL_TEXTLINE:
572 {
573 ResultIterator it(*this);
574 it.MoveToLogicalStartOfTextline();
575 it.IterateAndAppendUTF8TextlineText(&text);
576 }
577 break;
578 case RIL_WORD:
579 AppendUTF8WordText(&text);
580 break;
581 case RIL_SYMBOL:
582 {
583 bool reading_direction_is_ltr =
584 current_paragraph_is_ltr_ ^ in_minor_direction_;
585 if (at_beginning_of_minor_run_) {
586 text += reading_direction_is_ltr ? kLRM : kRLM;
587 }
588 text = it_->word()->BestUTF8(blob_index_, !reading_direction_is_ltr);
589 if (IsAtFinalSymbolOfWord()) AppendSuffixMarks(&text);
590 }
591 break;
592 }
593 int length = text.length() + 1;
594 char* result = new char[length];
595 strncpy(result, text.string(), length);
596 return result;
597}
598
599void ResultIterator::AppendUTF8WordText(STRING *text) const {
600 if (!it_->word()) return;

Callers 1

InitializeRowInfoFunction · 0.45

Calls 9

BestUTF8Method · 0.80
wordMethod · 0.45
NextMethod · 0.45
blockMethod · 0.45
lengthMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected