本文整理汇总了C++中SkString::appendHex方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::appendHex方法的具体用法?C++ SkString::appendHex怎么用?C++ SkString::appendHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::appendHex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoFormatString
// static
SkString SkPDFString::DoFormatString(const void* input, size_t len,
bool wideInput, bool wideOutput) {
SkASSERT(len <= kMaxLen);
const uint16_t* win = (const uint16_t*) input;
const char* cin = (const char*) input;
if (wideOutput) {
SkASSERT(wideInput);
SkString result;
result.append("<");
for (size_t i = 0; i < len; i++) {
result.appendHex(win[i], 4);
}
result.append(">");
return result;
}
// 7-bit clean is a heuristic to decide what string format to use;
// a 7-bit clean string should require little escaping.
bool sevenBitClean = true;
for (size_t i = 0; i < len; i++) {
SkASSERT(!wideInput || !(win[i] & ~0xFF));
char val = wideInput ? win[i] : cin[i];
if (val > '~' || val < ' ') {
sevenBitClean = false;
break;
}
}
SkString result;
if (sevenBitClean) {
result.append("(");
for (size_t i = 0; i < len; i++) {
SkASSERT(!wideInput || !(win[i] & ~0xFF));
char val = wideInput ? win[i] : cin[i];
if (val == '\\' || val == '(' || val == ')') {
result.append("\\");
}
result.append(&val, 1);
}
result.append(")");
} else {
result.append("<");
for (size_t i = 0; i < len; i++) {
SkASSERT(!wideInput || !(win[i] & ~0xFF));
unsigned char val = wideInput ? win[i] : cin[i];
result.appendHex(val, 2);
}
result.append(">");
}
return result;
}
示例2: TextToString
SkString* SkObjectParser::TextToString(const void* text, size_t byteLength,
SkPaint::TextEncoding encoding) {
SkString* decodedText = new SkString();
switch (encoding) {
case SkPaint::kUTF8_TextEncoding: {
decodedText->append("UTF-8: ");
decodedText->append((const char*)text, byteLength);
break;
}
case SkPaint::kUTF16_TextEncoding: {
decodedText->append("UTF-16: ");
size_t sizeNeeded = SkUTF16_ToUTF8((uint16_t*)text,
SkToS32(byteLength / 2),
nullptr);
SkAutoSTMalloc<0x100, char> utf8(sizeNeeded);
SkUTF16_ToUTF8((uint16_t*)text, SkToS32(byteLength / 2), utf8);
decodedText->append(utf8, sizeNeeded);
break;
}
case SkPaint::kUTF32_TextEncoding: {
decodedText->append("UTF-32: ");
const SkUnichar* begin = (const SkUnichar*)text;
const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLength);
for (const SkUnichar* unichar = begin; unichar < end; ++unichar) {
decodedText->appendUnichar(*unichar);
}
break;
}
case SkPaint::kGlyphID_TextEncoding: {
decodedText->append("GlyphID: ");
const uint16_t* begin = (const uint16_t*)text;
const uint16_t* end = (const uint16_t*)((const char*)text + byteLength);
for (const uint16_t* glyph = begin; glyph < end; ++glyph) {
decodedText->append("0x");
decodedText->appendHex(*glyph);
decodedText->append(" ");
}
break;
}
default:
decodedText->append("Unknown text encoding.");
break;
}
return decodedText;
}
示例3: writeHexAsText
bool SkWStream::writeHexAsText(uint32_t hex, int digits)
{
SkString tmp;
tmp.appendHex(hex, digits);
return this->write(tmp.c_str(), tmp.size());
}