tesseract  5.0.0-alpha-619-ge9db
tesseract::UNICHAR::const_iterator Class Reference

#include <unichar.h>

Public Member Functions

const_iteratoroperator++ ()
 
int operator* () const
 
int get_utf8 (char *buf) const
 
int utf8_len () const
 
bool is_legal () const
 
const char * utf8_data () const
 

Friends

class UNICHAR
 
bool operator== (const CI &lhs, const CI &rhs)
 
bool operator!= (const CI &lhs, const CI &rhs)
 

Detailed Description

Definition at line 109 of file unichar.h.

Member Function Documentation

◆ get_utf8()

int tesseract::UNICHAR::const_iterator::get_utf8 ( char *  buf) const

Definition at line 178 of file unichar.cpp.

178  {
179  ASSERT_HOST(it_ != nullptr);
180  const int len = utf8_step(it_);
181  if (len == 0) {
182  tprintf("WARNING: Illegal UTF8 encountered\n");
183  utf8_output[0] = ' ';
184  return 1;
185  }
186  strncpy(utf8_output, it_, len);
187  return len;
188 }

◆ is_legal()

bool tesseract::UNICHAR::const_iterator::is_legal ( ) const

Definition at line 200 of file unichar.cpp.

200  {
201  return utf8_step(it_) > 0;
202 }

◆ operator*()

int tesseract::UNICHAR::const_iterator::operator* ( ) const

Definition at line 167 of file unichar.cpp.

167  {
168  ASSERT_HOST(it_ != nullptr);
169  const int len = utf8_step(it_);
170  if (len == 0) {
171  tprintf("WARNING: Illegal UTF8 encountered\n");
172  return ' ';
173  }
174  UNICHAR uch(it_, len);
175  return uch.first_uni();
176 }

◆ operator++()

UNICHAR::const_iterator & tesseract::UNICHAR::const_iterator::operator++ ( )

Definition at line 153 of file unichar.cpp.

153  {
154  ASSERT_HOST(it_ != nullptr);
155  int step = utf8_step(it_);
156  if (step == 0) {
157  tprintf("ERROR: Illegal UTF8 encountered.\n");
158  for (int i = 0; i < 5 && it_[i] != '\0'; ++i) {
159  tprintf("Index %d char = 0x%x\n", i, it_[i]);
160  }
161  step = 1;
162  }
163  it_ += step;
164  return *this;
165 }

◆ utf8_data()

const char* tesseract::UNICHAR::const_iterator::utf8_data ( ) const
inline

Definition at line 137 of file unichar.h.

137  {
138  return it_;
139  }

◆ utf8_len()

int tesseract::UNICHAR::const_iterator::utf8_len ( ) const

Definition at line 190 of file unichar.cpp.

190  {
191  ASSERT_HOST(it_ != nullptr);
192  const int len = utf8_step(it_);
193  if (len == 0) {
194  tprintf("WARNING: Illegal UTF8 encountered\n");
195  return 1;
196  }
197  return len;
198 }

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const CI lhs,
const CI rhs 
)
friend

Definition at line 145 of file unichar.h.

145  {
146  return !(lhs == rhs);
147  }

◆ operator==

bool operator== ( const CI lhs,
const CI rhs 
)
friend

Definition at line 142 of file unichar.h.

142  {
143  return lhs.it_ == rhs.it_;
144  }

◆ UNICHAR

friend class UNICHAR
friend

Definition at line 150 of file unichar.h.


The documentation for this class was generated from the following files:
tesseract::UNICHAR::const_iterator::UNICHAR
friend class UNICHAR
Definition: unichar.h:150
ASSERT_HOST
#define ASSERT_HOST(x)
Definition: errcode.h:87
tesseract::UNICHAR::utf8_step
static int utf8_step(const char *utf8_str)
Definition: unichar.cpp:138
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34