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

Go to the source code of this file.


class  UTF8
 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...


#define MAYBE_VERIFY_UTF8(x)


bool IsUTF8 (const char *aString)
 Test a C string to see if it is UTF8 encoded. More...

Macro Definition Documentation


#define MAYBE_VERIFY_UTF8 (   x)

Definition at line 49 of file utf8.h.

Function Documentation

◆ IsUTF8()

bool IsUTF8 ( const char *  aString)

Test a C string to see if it is UTF8 encoded.

An ASCII string is a valid UTF8 string.

Definition at line 185 of file utf8.cpp.

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

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