33#include <Pt/Utf8Codec.h>
61 typedef Char value_type;
62 typedef std::ptrdiff_t difference_type;
63 typedef Char* pointer;
64 typedef const Char& reference;
65 typedef std::input_iterator_tag iterator_category;
98 , _value(other._value)
106 _value = other._value;
140 {
return _utf8 != other._utf8; }
145 {
return _utf8 == other._utf8; }
177 typedef Char value_type;
178 typedef std::ptrdiff_t difference_type;
179 typedef Char* pointer;
180 typedef const Char& reference;
181 typedef std::output_iterator_tag iterator_category;
234 void encode(
const Char& ch);
285 std::string
toBytes(
const char* utf8, std::size_t n);
291 return toBytes(bytes.data(), bytes.size());
296 std::string
fromBytes(
const char* bytes, std::size_t n);
302 return fromBytes(bytes.data(), bytes.size());
312 static const std::size_t _ibufSize = 16;
313 Char _ibuf[_ibufSize];
315 static const std::size_t _ebufSize = 32;
316 char _ebuf[_ebufSize];
356 bool advance(
const char* data, std::size_t n);
361 {
return ! _error && _need == 0; }
Converts between character encodings.
Definition Api-TextCodec.h:44
Utf8Appender & operator=(const Utf8Appender &other)
Assignment operator.
Definition Utf8.h:198
Utf8Appender(const Utf8Appender &other)
Copy constructor.
Definition Utf8.h:192
Utf8Appender & operator++()
No-op.
Definition Utf8.h:221
Utf8Appender & operator*()
No-op.
Definition Utf8.h:214
Utf8Appender & operator=(const Char &ch)
Encodes a unicode character to the target string.
Definition Utf8.h:206
Utf8Appender operator++(int)
No-op.
Definition Utf8.h:228
Utf8Appender(std::string &str)
Construct from UTF-8 encoded string.
Definition Utf8.h:186
Convert between unicode and UTF-8.
Definition Utf8Codec.h:44
UTF-8 string converter.
Definition Utf8.h:270
std::string fromBytes(const char *bytes, std::size_t n)
Decode from external encoding.
std::string toBytes(const std::string &bytes)
Encode to external encoding.
Definition Utf8.h:289
std::string fromBytes(const std::string &bytes)
Decode from external encoding.
Definition Utf8.h:300
Utf8Convert(TextCodec< Char, char > *codec)
Construct with codec.
~Utf8Convert()
Destructor.
std::string toBytes(const char *utf8, std::size_t n)
Encode to external encoding.
Utf8Iterator(const Utf8Iterator &other)
Copy constructor.
Definition Utf8.h:95
Utf8Iterator & operator++()
Decodes next character.
Definition Utf8.h:113
const Char & operator*() const
Returns current character.
Definition Utf8.h:134
bool operator==(const Utf8Iterator &other) const
Equality comparison.
Definition Utf8.h:144
Utf8Iterator(const char *utf8, std::size_t n)
Construct from UTF-8 string data.
Definition Utf8.h:77
Utf8Iterator(const std::string &bytes)
Construct from UTF-8 encoded string.
Definition Utf8.h:86
Utf8Iterator & operator=(const Utf8Iterator &other)
Assignment operator.
Definition Utf8.h:103
bool operator!=(const Utf8Iterator &other) const
Inequality comparison.
Definition Utf8.h:139
Utf8Iterator operator++(int)
Decodes next character.
Definition Utf8.h:125
Utf8Iterator()
Construct end iterator.
Definition Utf8.h:70
Utf8Validator()
Creates an empty validator.
Definition Utf8.h:346
bool advance(const char *data, std::size_t n)
Feeds the next bytes.
bool finish() const
Returns true if no error occurred and no character is incomplete.
Definition Utf8.h:360
void reset()
Returns the validator to the empty initial state.
Definition Utf8.h:365
bool isValidUtf8(const char *data, std::size_t n)
Returns true if data is a complete well-formed UTF-8 sequence.
Definition Utf8.h:383
Core module.
Definition Allocator.h:33
Unicode character type.
Definition String.h:67