KiCad PCB EDA Suite
utf8.h File Reference
#include <string>
#include <wx/string.h>

Go to the source code of this file.

Classes

class  UTF8
 UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and from wxString, to and from std::string, and has non-mutating iteration over unicode characters. More...
 
class  UTF8::uni_iter
 uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string. More...
 

Macros

#define UTF8_H_
 
#define MAYBE_VERIFY_UTF8(x)
 
#define MAYBE_VERIFY_UTF8(x)
 

Functions

bool IsUTF8 (const char *aString)
 Function IsUTF8 tests a c-string to see if it is UTF8 encoded. More...
 

Macro Definition Documentation

◆ MAYBE_VERIFY_UTF8 [1/2]

#define MAYBE_VERIFY_UTF8 (   x)

◆ MAYBE_VERIFY_UTF8 [2/2]

#define MAYBE_VERIFY_UTF8 (   x)

Definition at line 47 of file utf8.h.

◆ UTF8_H_

#define UTF8_H_

Definition at line 27 of file numeric_evaluator.cpp.

Function Documentation

◆ IsUTF8()

bool IsUTF8 ( const char *  aString)

Function IsUTF8 tests a c-string to see if it is UTF8 encoded.

BTW an ASCII string is a valid UTF8 string.

Definition at line 185 of file utf8.cpp.

186 {
187  int len = strlen( aString );
188 
189  if( len )
190  {
191  const unsigned char* next = (unsigned char*) aString;
192  const unsigned char* end = next + len;
193 
194  while( next < end )
195  {
196  int charLen = UTF8::uni_forward( next, NULL );
197 
198  if( charLen == 0 )
199  return false;
200 
201  next += charLen;
202  }
203 
204  // uni_forward() should find the exact end if it is truly UTF8
205  if( next > end )
206  return false;
207  }
208 
209  return true;
210 }
CITER next(CITER it)
Definition: ptree.cpp:130
#define NULL
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=NULL)
Function uni_forward advances over a single UTF8 encoded multibyte character, capturing the unicode c...
Definition: utf8.cpp:73

References next(), NULL, and UTF8::uni_forward().