5#include <fifechan/utf8stringeditor.hpp>
6#include <fifechan/util/utf8/utf8.hpp>
15 std::string::const_iterator c;
16 std::string::const_iterator e;
18 c = text.begin() + byteOffset;
22 return std::string(text.begin(), c).size();
27 std::string::const_iterator c;
28 std::string::const_iterator b;
30 c = text.begin() + byteOffset;
34 return std::string(b, c).size();
39 std::string::iterator begin;
40 std::string::iterator cur;
41 begin = text.begin() + byteOffset;
43 utf8::next(cur, text.end());
45 text = std::string(text.begin(), begin) + std::string(cur, text.end());
52 std::string::iterator cut;
56 newText = text.substr(0, byteOffset) +
" ";
58 utf8::append(ch, newText.begin() + byteOffset);
60 cut = newText.begin() + byteOffset;
61 utf8::next(cut, newText.end());
63 newText = std::string(newText.begin(), cut);
64 newOffset = newText.size();
66 text = newText + text.substr(byteOffset);
73 return utf8::distance(text.begin(), text.begin() + byteOffset);
78 std::string::const_iterator cur;
79 std::string::const_iterator end;
89 for (i = 0; i < charIndex && cur != end; i++) {
93 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.