31 #include "utf8stringeditor.h"
38 std::string::const_iterator c, e;
40 c = text.begin() + byteOffset;
44 return std::string(text.begin(), c).size();
49 std::string::const_iterator c, b;
51 c = text.begin() + byteOffset;
55 return std::string(b, c).size();
60 std::string::iterator begin, cur;
61 begin = text.begin() + byteOffset;
63 utf8::next(cur, text.end());
65 text = std::string(text.begin(), begin) + std::string(cur, text.end());
72 std::string::iterator cut;
76 newText = text.substr(0, byteOffset) +
" ";
78 utf8::append(ch, newText.begin() + byteOffset);
80 cut = newText.begin() + byteOffset;
81 utf8::next(cut, newText.end());
83 newText = std::string(newText.begin(), cut);
84 newOffset = newText.size();
86 text = newText + text.substr(byteOffset);
93 return utf8::distance(text.begin(), text.begin() + byteOffset);
98 std::string::const_iterator cur, end;
101 if (charIndex < 0)
return 0;
106 for(i = 0; i < charIndex && cur != end; i++) {
107 utf8::next(cur, end);
110 return std::string(text.begin(), cur).size();
static int getOffset(const std::string &text, int charIndex)
static int eraseChar(std::string &text, int byteOffset)
static int prevChar(const std::string &text, int byteOffset)
static int nextChar(const std::string &text, int byteOffset)
static int countChars(const std::string &text, int byteOffset)
static int insertChar(std::string &text, int byteOffset, int ch)