5#include <fifechan/utf8stringeditor.hpp>
16 std::string::const_iterator c;
17 std::string::const_iterator e;
19 c = text.begin() + byteOffset;
23 return std::string(text.begin(), c).size();
28 std::string::const_iterator c;
29 std::string::const_iterator b;
31 c = text.begin() + byteOffset;
35 return std::string(b, c).size();
40 std::string::iterator begin;
41 std::string::iterator cur;
42 begin = text.begin() + byteOffset;
44 utf8::next(cur, text.end());
46 text = std::string(text.begin(), begin) + std::string(cur, text.end());
53 std::string::iterator cut;
57 newText = text.substr(0, byteOffset) +
" ";
59 utf8::append(ch, newText.begin() + byteOffset);
61 cut = newText.begin() + byteOffset;
62 utf8::next(cut, newText.end());
64 newText = std::string(newText.begin(), cut);
65 newOffset = newText.size();
67 text = newText + text.substr(byteOffset);
74 return utf8::distance(text.begin(), text.begin() + byteOffset);
79 std::string::const_iterator cur;
80 std::string::const_iterator end;
90 for (i = 0; i < charIndex && cur != end; i++) {
94 return std::string(text.begin(), cur).size();
static int insertChar(std::string &text, int byteOffset, int ch)
Insert a character at specified byte offset.
static int countChars(std::string const &text, int byteOffset)
Counts characters up to byteOffset.
static int eraseChar(std::string &text, int byteOffset)
Erase character at specified byte offset.
static int getOffset(std::string const &text, int charIndex)
Gets byte offset for character index.
static int nextChar(std::string const &text, int byteOffset)
Returns byte offset of the next character.
static int prevChar(std::string const &text, int byteOffset)
Returns byte offset of the previous character.