本文整理汇总了C++中String::AppendUTF8方法的典型用法代码示例。如果您正苦于以下问题:C++ String::AppendUTF8方法的具体用法?C++ String::AppendUTF8怎么用?C++ String::AppendUTF8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::AppendUTF8方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateText
void LineEdit::UpdateText()
{
unsigned utf8Length = line_.LengthUTF8();
if (!echoCharacter_)
text_->SetText(line_);
else
{
String echoText;
for (unsigned i = 0; i < utf8Length; ++i)
echoText.AppendUTF8(echoCharacter_);
text_->SetText(echoText);
}
if (cursorPosition_ > utf8Length)
{
cursorPosition_ = utf8Length;
UpdateCursor();
}
using namespace TextChanged;
VariantMap& eventData = GetEventDataMap();
eventData[P_ELEMENT] = this;
eventData[P_TEXT] = line_;
SendEvent(E_TEXTCHANGED, eventData);
}
示例2: while
String String::SubstringUTF8(unsigned pos) const
{
unsigned utf8Length = LengthUTF8();
unsigned byteOffset = ByteOffsetUTF8(pos);
String ret;
while (pos < utf8Length)
{
ret.AppendUTF8(NextUTF8Char(byteOffset));
++pos;
}
return ret;
}
示例3: while
String String::SubstringUTF8(size_t pos) const
{
size_t utf8Length = LengthUTF8();
size_t byteOffset = ByteOffsetUTF8(pos);
String ret;
while (pos < utf8Length)
{
ret.AppendUTF8(NextUTF8Char(byteOffset));
++pos;
}
return ret;
}
示例4: OnChar
void LineEdit::OnChar(unsigned c, int buttons, int qualifiers)
{
if (!editable_)
return;
bool changed = false;
// If only CTRL is held down, do not edit
if ((qualifiers & (QUAL_CTRL | QUAL_ALT)) == QUAL_CTRL)
return;
if (c >= 0x20 && (!maxLength_ || line_.LengthUTF8() < maxLength_))
{
String charStr;
charStr.AppendUTF8(c);
if (!text_->GetSelectionLength())
{
if (cursorPosition_ == line_.LengthUTF8())
line_ += charStr;
else
line_ = line_.SubstringUTF8(0, cursorPosition_) + charStr + line_.SubstringUTF8(cursorPosition_);
++cursorPosition_;
}
else
{
// If a selection exists, erase it first
unsigned start = text_->GetSelectionStart();
unsigned length = text_->GetSelectionLength();
if (start + length < line_.LengthUTF8())
line_ = line_.SubstringUTF8(0, start) + charStr + line_.SubstringUTF8(start + length);
else
line_ = line_.SubstringUTF8(0, start) + charStr;
cursorPosition_ = start + 1;
}
changed = true;
}
if (changed)
{
text_->ClearSelection();
UpdateText();
UpdateCursor();
}
}
示例5: ReadLine
String ReadLine()
{
String ret;
#ifdef _WIN32
HANDLE input = GetStdHandle(STD_INPUT_HANDLE);
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
if (input == INVALID_HANDLE_VALUE || output == INVALID_HANDLE_VALUE)
return ret;
// Use char-based input
SetConsoleMode(input, ENABLE_PROCESSED_INPUT);
INPUT_RECORD record;
DWORD events = 0;
DWORD readEvents = 0;
if (!GetNumberOfConsoleInputEvents(input, &events))
return ret;
while (events--)
{
ReadConsoleInputW(input, &record, 1, &readEvents);
if (record.EventType == KEY_EVENT && record.Event.KeyEvent.bKeyDown)
{
unsigned c = record.Event.KeyEvent.uChar.UnicodeChar;
if (c)
{
if (c == '\b')
{
PrintUnicode("\b \b");
size_t length = currentLine.LengthUTF8();
if (length)
currentLine = currentLine.SubstringUTF8(0, length - 1);
}
else if (c == '\r')
{
PrintUnicode("\n");
ret = currentLine;
currentLine.Clear();
return ret;
}
else
{
// We have disabled echo, so echo manually
wchar_t out = (wchar_t)c;
DWORD charsWritten;
WriteConsoleW(output, &out, 1, &charsWritten, 0);
currentLine.AppendUTF8(c);
}
}
}
}
#else
int flags = fcntl(STDIN_FILENO, F_GETFL);
fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK);
for (;;)
{
int ch = fgetc(stdin);
if (ch >= 0 && ch != '\n')
ret += (char)ch;
else
break;
}
#endif
return ret;
}
示例6: ReadJSONString
bool JSONValue::ReadJSONString(String& dest, const char*& pos, const char*& end, bool inQuote)
{
char c;
if (!inQuote)
{
if (!NextChar(c, pos, end, true) || c != '\"')
return false;
}
dest.Clear();
for (;;)
{
if (!NextChar(c, pos, end, false))
return false;
if (c == '\"')
break;
else if (c != '\\')
dest += c;
else
{
if (!NextChar(c, pos, end, false))
return false;
switch (c)
{
case '\\':
dest += '\\';
break;
case '\"':
dest += '\"';
break;
case 'b':
dest += '\b';
break;
case 'f':
dest += '\f';
break;
case 'n':
dest += '\n';
break;
case 'r':
dest += '\r';
break;
case 't':
dest += '\t';
break;
case 'u':
{
/// \todo Doesn't handle unicode surrogate pairs
unsigned code;
/// @todo check return value
code = strtol(pos, 0, 16);
pos += 4;
dest.AppendUTF8(code);
}
break;
}
}
}
return true;
}