84 using storage_type = std::vector<codepoint>;
112 bool Empty()
const {
return store.empty(); }
118 size_t Size()
const {
return store.size(); }
130 void Reserve(
size_t sz) { store.reserve(sz); }
167 const storage_type&
Data()
const {
return store; }
240 std::string
Substr(
size_t pos,
size_t n = (-1))
const;
void Clear()
Clears the contents of the string and makes it null.
bool Remove(size_t pos, size_t n=1)
Remove n character from the position pos.
size_t RawSize() const
Returns the number of bytes of this string.
Definition utf8helper.h:124
std::string Substr(size_t pos, size_t n=(-1)) const
Returns a std::string object with the substring of n characters of this string, starting at the posit...
bool Insert(size_t pos, codepoint u, utf8helper::Transform func=utf8helper::TransformNop)
Insert the character u at the position pos.
UTF8String(const std::string &text, utf8helper::Transform)
Contructs UTF8String object containing the text with specified transformation.
codepoint operator[](size_t pos) const
Returns the character at the position pos.
Definition utf8helper.h:161
UTF8String(const UTF8String &)=default
UTF8String & Append(codepoint u, utf8helper::Transform func=utf8helper::TransformNop)
Add character to the string.
const storage_type & Data() const
Returns the characters contained in this string.
Definition utf8helper.h:167
UTF8String & Transform(const std::string &text, utf8helper::Transform)
Transform and assign the text to the string.
UTF8String & Transform(utf8helper::Transform)
Apply transformation to the string.
UTF8String & operator<<(char cc)
Definition utf8helper.h:151
UTF8String & Append(const storage_type &data, utf8helper::Transform func=utf8helper::TransformNop)
Add characters to the string.
size_t Size() const
Return the number of character of this string.
Definition utf8helper.h:118
size_t Insert(size_t pos, const storage_type &data, utf8helper::Transform func=utf8helper::TransformNop)
Insert characters at the position pos.
void Reserve(size_t sz)
Attempts to allocate memory for at least sz characters.
Definition utf8helper.h:130
UTF8String()
Contructs empty UTF8String object with transformation nop.
UTF8String(utf8helper::Transform)
Contructs empty UTF8String object with the specified transformation.
UTF8String(const std::string &text)
Contructs UTF8String object containing the text.
void WriteByte(char cc)
Push one more byte into this string. A character is added to this string on each valid sequence.
std::string ToStdString() const
Returns a std::string object with the data contained in this string.
bool Empty() const
Definition utf8helper.h:112
Definition utf8helper.h:29
codepoint TransformLower(const character *, int)
uint8_t byte
Definition utf8helper_charmap.h:36
std::string UTF8Normalize(const std::string &text)
codepoint TransformNop(const character *, int)
std::string UTF8ToLower(const std::string &text)
codepoint TransformUpper(const character *, int)
codepoint TransformCapitalize(const character *, int)
codepoint TransformTransliterate(const character *, int)
codepoint TransformNormalize(const character *, int)
std::string UTF8Capitalize(const std::string &text)
std::string UTF8Transliterate(const std::string &text)
std::string UTF8ToUpper(const std::string &text)
uint32_t codepoint
Definition utf8helper_charmap.h:37
codepoint(*)(const character *, int context) Transform
functor implements desired transformation of the character It has 2 arguments:
Definition utf8helper.h:49
Parse and transform an UTF8 string.
Definition utf8helper.h:69
Parser(utf8helper::Transform func)
int context
Definition utf8helper.h:73
Parser(const Parser &)=default
Exit
Definition utf8helper.h:70
@ Error
Definition utf8helper.h:70
@ Done
Definition utf8helper.h:70
@ Continue
Definition utf8helper.h:70
codepoint u
Definition utf8helper.h:76
byte b[3]
Definition utf8helper.h:74
Exit(* run)(Parser *, byte)
Definition utf8helper.h:72
utf8helper::Transform func
Definition utf8helper.h:71
char u_size
Definition utf8helper.h:75
Definition utf8helper_charmap.h:41