コード例 #1
0
ファイル: TMSOURCE.CPP プロジェクト: cdaffara/symbiandump-os2
/**
The default function to map a character to the character drawn, or to 0xFFFF if the character is not to be drawn.
*/
EXPORT_C TUint MTmCustom::Map(TUint aChar) const
	{
	// Deal with some easy cases without calling TChar::GetCategory.
	if (aChar >= 0x0020 && aChar <= 0x007E) // ascii
		return aChar;
	
	if (aChar >= 0x00A1 && aChar <= 0x021F) // latin supplement & contiguous latin extended
		{
		if (aChar == CEditableText::EPotentialHyphen) //0x00AD
			return '-'; //0x002D
		return aChar;
		}
		
	if (aChar >= 0xE000 && aChar <= 0xF8FF) // private use area
		return aChar;

	// All special hyphens are represented as an ordinary  hyphen.
	if (aChar == CEditableText::ENonBreakingHyphen)
		return '-';

	// Picture characters are turned into 0x25A3 (black square inside white square).
	if (aChar == CEditableText::EPictureCharacter)
		return 0x25A3;

	// Zero-width space not drawn
	if (aChar == 0x200B)
		return 0xFFFF;
	// Hard space rendered as normal space
	if (aChar == 0xA0)
		return 0x20;
	// don't show corrupt surrogate
	if (IsSurrogate(aChar))
		{
		//This is an informationl message. Commented out to avoid annoyance
		//RDebug::Print(_L("Error: Do not show corrupt surrogate %X."), aChar);
		return 0xFFFF;
		}
		
	TChar::TCategory cat = TChar(aChar).GetCategory();
		
	// Control characters and unassigned characters are usually not understood
	// by CFont::DrawText. Some are and must be present to get the correct
	// result.
	if (cat > TChar::EZsCategory
		&& aChar != KZeroWidthJoiner
		&& aChar != KZeroWidthNonJoiner)
		return 0xFFFF;

	// Other characters are left alone.
	return aChar;
	}
コード例 #2
0
	void ExtractNextCodePoint()
	{
		next_it = it;

		if (end - next_it <= 0)
		{
			next_code_point = ::unicode_iterator::CP_END_OF_STREAM;
			return;
		}
		char16_t high = FromEndianness(endianness, *(next_it++));

		if (!IsSurrogate(high))
		{
			next_code_point = high;
			return;
		}

		if (!IsLead(high))
		{
			next_code_point = ::unicode_iterator::CP_CORRUPT;
			return;
		}

		if (end - next_it <= 0)
		{
			next_code_point = ::unicode_iterator::CP_END_OF_STREAM;
			return;
		}
		char16_t low = FromEndianness(endianness, *(next_it++));

		if (!IsTrail(low))
		{
			next_code_point = ::unicode_iterator::CP_CORRUPT;
			return;
		}

		next_code_point = (char32_t(high - 0xd800) << 10) + (low - 0xdc00);
	}