33 #include <Pt/Utf8Codec.h>
34 #include <Pt/String.h>
62 typedef std::ptrdiff_t difference_type;
65 typedef std::input_iterator_tag iterator_category;
97 , _value(other._value)
106 _value = other._value;
140 {
return _utf8 != other._utf8; }
145 {
return _utf8 == other._utf8; }
178 typedef std::ptrdiff_t difference_type;
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];
321 #endif // include guard
UTF-8 string input iterator.
Definition: Utf8.h:58
Utf8Appender(const Utf8Appender &other)
Copy constructor.
Definition: Utf8.h:192
const Char & operator*() const
Returns current character.
Definition: Utf8.h:134
Utf8Iterator operator++(int)
Decodes next character.
Definition: Utf8.h:125
Utf8Appender & operator=(const Utf8Appender &other)
Assignment operator.
Definition: Utf8.h:198
Utf8Appender & operator*()
No-op.
Definition: Utf8.h:214
Utf8Iterator(const char *utf8, std::size_t n)
Construct from UTF-8 string data.
Definition: Utf8.h:77
Utf8Appender & operator++()
No-op.
Definition: Utf8.h:221
std::string fromBytes(const std::string &bytes)
Decode from external encoding.
Definition: Utf8.h:300
bool operator!=(const Utf8Iterator &other) const
Inequality comparison.
Definition: Utf8.h:139
Utf8Iterator()
Construct end iterator.
Definition: Utf8.h:70
Utf8Appender & operator=(const Char &ch)
Encodes a unicode character to the target string.
Definition: Utf8.h:206
Unicode character type.
Definition: String.h:66
std::string toBytes(const std::string &bytes)
Encode to external encoding.
Definition: Utf8.h:289
Utf8Iterator & operator=(const Utf8Iterator &other)
Assignment operator.
Definition: Utf8.h:103
Utf8Iterator(const Utf8Iterator &other)
Copy constructor.
Definition: Utf8.h:95
Utf8Appender(std::string &str)
Construct from UTF-8 encoded string.
Definition: Utf8.h:186
Utf8Appender operator++(int)
No-op.
Definition: Utf8.h:228
bool operator==(const Utf8Iterator &other) const
Equality comparison.
Definition: Utf8.h:144
UTF-8 string output iterator.
Definition: Utf8.h:174
Utf8Iterator & operator++()
Decodes next character.
Definition: Utf8.h:113
UTF-8 string converter.
Definition: Utf8.h:269
Utf8Iterator(const std::string &bytes)
Construct from UTF-8 encoded string.
Definition: Utf8.h:86
Convert between unicode and UTF-8.
Definition: Utf8Codec.h:43