当前位置: 首页>>代码示例>>C++>>正文


C++ Ucs2String::size方法代码示例

本文整理汇总了C++中zlunicodeutil::Ucs2String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Ucs2String::size方法的具体用法?C++ Ucs2String::size怎么用?C++ Ucs2String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zlunicodeutil::Ucs2String的用法示例。


在下文中一共展示了Ucs2String::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseLink

std::string DocBookReader::parseLink(ZLUnicodeUtil::Ucs2String s, bool urlencode) {
	//TODO add support for HYPERLINK like that:
	// [0x13] HYPERLINK "http://site.ru/some text" \t "_blank" [0x14] text [0x15]
	//Current implementation search for last QUOTE, so, it reads \t and _blank as part of link
	//Last quote searching is need to handle link like that:
	// [0x13] HYPERLINK "http://yandex.ru/yandsearch?text='some text' и "some text2"" [0x14] link text [0x15]

	static const ZLUnicodeUtil::Ucs2Char QUOTE = 0x22;
	size_t i, first = 0;
	//TODO maybe functions findFirstOf and findLastOf should be in ZLUnicodeUtil class
	for (i = 0; i < s.size(); ++i) {
		if (s.at(i) == QUOTE) {
			first = i;
			break;
		}
	}
	if (i == s.size()) {
		return std::string();
	}
	size_t j, last = 0;
	for (j = s.size(); j > 0 ; --j) {
		if (s.at(j - 1) == QUOTE) {
			last = j - 1;
			break;
		}
	}
	if (j == 0 || last == first) {
		return std::string();
	}

	ZLUnicodeUtil::Ucs2String link;
	for (size_t k = first + 1; k < last; ++k) {
		ZLUnicodeUtil::Ucs2Char ch = s.at(k);
		if (urlencode && ZLUnicodeUtil::isSpace(ch)) {
			//TODO maybe implement function for encoding all signs in url, not only spaces and quotes
			//TODO maybe add backslash support
			link.push_back('%');
			link.push_back('2');
			link.push_back('0');
		} else if (urlencode && ch == QUOTE) {
			link.push_back('%');
			link.push_back('2');
			link.push_back('2');
		} else {
			link.push_back(ch);
		}
	}
	std::string utf8String;
	ZLUnicodeUtil::ucs2ToUtf8(utf8String, link);
	return utf8String;
}
开发者ID:37Jayden,项目名称:bho,代码行数:51,代码来源:DocBookReader.cpp

示例2: sizeof

void ZLWin32PaintContext::setFont(const std::string &family, int size, bool bold, bool italic) {
	if (size < 4) {
		size = 4;
	}
	if (myDisplayContext == 0) {
		return;
	}
	// TODO: optimize
	LOGFONT logicalFont;
	memset(&logicalFont, 0, sizeof(LOGFONT));
	logicalFont.lfHeight = size;
	logicalFont.lfWeight = bold ? FW_BOLD : FW_REGULAR;
	logicalFont.lfItalic = italic;
	logicalFont.lfQuality = 5 /*CLEARTYPE_QUALITY*/;
	const int len = std::min((int)family.length(), LF_FACESIZE - 1);
	ZLUnicodeUtil::Ucs2String str;
	ZLUnicodeUtil::utf8ToUcs2(str, family.data(), len);
	str.push_back(0);
	memcpy(logicalFont.lfFaceName, ::wchar(str), 2 * str.size());
	HFONT font = CreateFontIndirect(&logicalFont);
	DeleteObject(SelectObject(myDisplayContext, font));

	GetTextMetrics(myDisplayContext, &myTextMetric);
	mySpaceWidth = -1;
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:25,代码来源:ZLWin32PaintContext.cpp

示例3: toolbar

void ZLWin32ApplicationWindow::setTooltip(TOOLTIPTEXT &tooltip) {
	Toolbar &tb = toolbar(isFullscreen() ? FULLSCREEN_TOOLBAR : WINDOW_TOOLBAR);
	if (tb.hwnd == 0) {
		return;
	}
	ZLToolbar::ItemPtr item = tb.TBItemByActionCode[tooltip.hdr.idFrom];
	if (!item.isNull()) {
		const ZLToolbar::AbstractButtonItem &button =
			(const ZLToolbar::AbstractButtonItem&)*item;
		ZLUnicodeUtil::Ucs2String tooltipBuffer;
		::createNTWCHARString(tooltipBuffer, button.tooltip());
		size_t length = std::max(tooltipBuffer.size(), (size_t)80);
		memcpy((char*)tooltip.szText, (char*)::wchar(tooltipBuffer), 2 * length);
		tooltip.uFlags = TTF_DI_SETITEM;
	}
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:16,代码来源:ZLWin32ApplicationWindow.cpp

示例4: drawString

void ZLQtPaintContext::drawString(int x, int y, const char *str, int len, bool rtl) {
	if (rtl) {
		static ZLUnicodeUtil::Ucs2String ucs2Str;
		ucs2Str.clear();
		ZLUnicodeUtil::utf8ToUcs2(ucs2Str, str, len);
		QString qStr;
		FriBidiChar ch;
		for (int i = ucs2Str.size() - 1; i >= 0; --i) {
			fribidi_get_mirror_char(ucs2Str[i], &ch);
			qStr.append(QChar(ch));
		}
		myPainter->drawText(x, y, qStr);
	} else {
		QString qStr = QString::fromUtf8(str, len);
		myPainter->drawText(x, y, qStr);
	}
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:17,代码来源:ZLQtPaintContext.cpp

示例5: addStyleEntry

void ZLTextModel::addStyleEntry(const ZLTextStyleEntry &entry) {
	// +++ calculating entry size
	std::size_t len = 4; // entry type + feature mask
	for (int i = 0; i < ZLTextStyleEntry::NUMBER_OF_LENGTHS; ++i) {
		if (entry.isFeatureSupported((ZLTextStyleEntry::Feature)i)) {
			len += 4; // each supported length
		}
	}
	if (entry.isFeatureSupported(ZLTextStyleEntry::ALIGNMENT_TYPE)) {
		len += 2;
	}
	ZLUnicodeUtil::Ucs2String fontFamily;
	if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_FAMILY)) {
		ZLUnicodeUtil::utf8ToUcs2(fontFamily, entry.fontFamily());
		len += 2 + fontFamily.size() * 2;
	}
	if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_STYLE_MODIFIER)) {
		len += 2;
	}
	// --- calculating entry size

/*
	EntryCount += 1;
	EntryLen += len;
	std::string debug = "style entry counter: ";
	ZLStringUtil::appendNumber(debug, EntryCount);
	debug += "/";
	ZLStringUtil::appendNumber(debug, EntryLen);
	ZLLogger::Instance().println(ZLLogger::DEFAULT_CLASS, debug);
*/

	// +++ writing entry
	myLastEntryStart = myAllocator->allocate(len);
	char *address = myLastEntryStart;

	*address++ = entry.entryKind();
	*address++ = 0;
	address = ZLCachedMemoryAllocator::writeUInt16(address, entry.myFeatureMask);

	for (int i = 0; i < ZLTextStyleEntry::NUMBER_OF_LENGTHS; ++i) {
		if (entry.isFeatureSupported((ZLTextStyleEntry::Feature)i)) {
			const ZLTextStyleEntry::LengthType &len = entry.myLengths[i];
			address = ZLCachedMemoryAllocator::writeUInt16(address, len.Size);
			*address++ = len.Unit;
			*address++ = 0;
		}
	}
	if (entry.isFeatureSupported(ZLTextStyleEntry::ALIGNMENT_TYPE)) {
		*address++ = entry.myAlignmentType;
		*address++ = 0;
	}
	if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_FAMILY)) {
		address = ZLCachedMemoryAllocator::writeString(address, fontFamily);
	}
	if (entry.isFeatureSupported(ZLTextStyleEntry::FONT_STYLE_MODIFIER)) {
		*address++ = entry.mySupportedFontModifier;
		*address++ = entry.myFontModifier;
	}
	// --- writing entry

	myParagraphs.back()->addEntry(myLastEntryStart);
	++myParagraphLengths.back();
}
开发者ID:MastAvalons,项目名称:FBReaderJ,代码行数:63,代码来源:ZLTextModel.cpp


注:本文中的zlunicodeutil::Ucs2String::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。