tesseract 4.1.1
Loading...
Searching...
No Matches
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 107 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}
#define ASSERT_HOST(x)
Definition: errcode.h:88
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:35
static int utf8_step(const char *utf8_str)
Definition: unichar.cpp:138

◆ 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 135 of file unichar.h.

135 {
136 return it_;
137 }

◆ 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 143 of file unichar.h.

143 {
144 return !(lhs == rhs);
145 }

◆ operator==

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

Definition at line 140 of file unichar.h.

140 {
141 return lhs.it_ == rhs.it_;
142 }

◆ UNICHAR

friend class UNICHAR
friend

Definition at line 148 of file unichar.h.


The documentation for this class was generated from the following files: