44bool IsUTF8(
const char* aString );
47#if defined(UTF8_VERIFY)
48 #define MAYBE_VERIFY_UTF8(x) wxASSERT( IsUTF8(x) )
50 #define MAYBE_VERIFY_UTF8(x)
74 UTF8(
const wxString& o );
86 UTF8(
const wchar_t* txt );
88 UTF8(
const std::string& o ) :
106 std::string::size_type
find(
char c )
const {
return m_s.find( c ); }
107 std::string::size_type
find(
char c,
size_t s )
const {
return m_s.find( c, s ); }
110 std::string::size_type
length()
const {
return m_s.length(); }
111 std::string::size_type
size()
const {
return m_s.size(); }
112 int compare(
const std::string& s )
const {
return m_s.compare( s ); }
123 std::string::size_type pos = 0 )
const
125 return m_s.find_first_of( str, pos );
137 m_s.operator+=( ch );
156 static constexpr std::string::size_type
npos = -1;
183 std::string
substr(
size_t pos = 0,
size_t len =
npos )
const
185 return m_s.substr( pos, len );
188 operator const std::string& ()
const {
return m_s; }
193 operator wxString ()
const;
197 std::string::const_iterator
begin()
const {
return m_s.begin(); }
198 std::string::const_iterator
end()
const {
return m_s.end(); }
272 const unsigned char*
it;
276 it( (const unsigned char*) start )
305 static int uni_forward(
const unsigned char* aSequence,
unsigned* aResult =
nullptr );
313std::ostream&
operator<<( std::ostream& aStream,
const UTF8& aRhs );
uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string...
uni_iter(const uni_iter &o)
unsigned operator*() const
return unicode at current position
bool operator!=(const uni_iter &other) const
uni_iter(const char *start)
bool operator<(const uni_iter &other) const
Since the ++ operators advance more than one byte, this is your best loop termination test,...
uni_iter operator-(int aVal) const
bool operator>=(const uni_iter &other) const
bool operator<=(const uni_iter &other) const
bool operator==(const uni_iter &other) const
bool operator>(const uni_iter &other) const
uni_iter operator++(int)
post-increment and return uni_iter at initial position
const uni_iter & operator++()
pre-increment and return uni_iter at new position
unsigned operator->() const
return unicode at current position
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
UTF8 & operator+=(const UTF8 &str)
static constexpr std::string::size_type npos
std::string::const_iterator begin() const
UTF8 & operator=(const std::string &o)
std::string::size_type length() const
std::string::size_type find(char c) const
bool operator!=(const UTF8 &rhs) const
std::string substr(size_t pos=0, size_t len=npos) const
std::string::size_type find(char c, size_t s) const
uni_iter uend() const
Return a uni_iter initialized to the end of "this" UTF8 byte sequence.
bool operator==(const std::string &rhs) const
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=nullptr)
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes,...
UTF8(const std::string &o)
UTF8 & operator+=(const char *s)
int compare(const std::string &s) const
std::string::size_type find_first_of(const std::string &str, std::string::size_type pos=0) const
UTF8 & operator+=(char ch)
UTF8(const char *txt)
This is a constructor for which you could end up with non-UTF8 encoding, but that would be your fault...
const char * c_str() const
bool operator<(const UTF8 &rhs) const
std::string::size_type size() const
uni_iter ubegin() const
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
UTF8 & operator=(const char *s)
bool operator==(const char *s) const
std::string::const_iterator end() const
UTF8 & operator=(const wxString &o)
bool operator==(const UTF8 &rhs) const
bool operator>(const UTF8 &rhs) const
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
#define MAYBE_VERIFY_UTF8(x)
bool IsUTF8(const char *aString)
Test a C string to see if it is UTF8 encoded.