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

Go to the source code of this file.


class  UTF8
 Class 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
 class uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string. More...


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


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

Macro Definition Documentation


#define MAYBE_VERIFY_UTF8 (   x)


#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 173 of file utf8.cpp.

174 {
175  int len = strlen( aString );
177  if( len )
178  {
179  const unsigned char* next = (unsigned char*) aString;
180  const unsigned char* end = next + len;
182  try
183  {
184  while( next < end )
185  {
186  next += UTF8::uni_forward( next, NULL );
187  }
189  // uni_forward() should find the exact end if it is truly UTF8
190  if( next > end )
191  return false;
192  }
193  catch( const IO_ERROR& )
194  {
195  return false;
196  }
197  }
199  return true;
200 }
CITER next(CITER it)
Definition: ptree.cpp:130
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
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

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