textrendering/textformatting/tagma/TmChunk.cpp
changeset 24 71313a964664
parent 0 1fb32624e06b
child 49 4d76f1414957
--- a/textrendering/textformatting/tagma/TmChunk.cpp	Mon May 03 14:13:26 2010 +0300
+++ b/textrendering/textformatting/tagma/TmChunk.cpp	Fri May 14 17:40:32 2010 +0300
@@ -20,25 +20,6 @@
 #include "InlineText.h"
 #include "frmUtils.h"
 
-inline TBool IsSurrogate(TText a) { return 0xD800 == (a & 0xF800); }
-inline TBool IsHighSurrogate(TText a) { return 0xD800 == (a & 0xFC00); }
-inline TBool IsLowSurrogate(TText a) { return 0xDC00 == (a & 0xFC00); }
-inline TChar JoinSurrogates(TText aHigh, TText aLow)
-	{
-	return ((aHigh - 0xd7f7) << 10) + aLow;
-	}
-
-
-inline TText16 GetHighSurrogate(TUint aChar)
-	{
-	return STATIC_CAST(TText16, 0xD7C0 + (aChar >> 10));
-	}
-
-inline TText16 GetLowSurrogate(TUint aChar)
-	{
-	return STATIC_CAST(TText16, 0xDC00 | (aChar & 0x3FF));
-	}
-
 
 TTmChunk::TTmChunk():
 	iDocPos(0),
@@ -107,7 +88,7 @@
 				}
 			}
 
-		if ( IsLowSurrogate( *current_character ) )
+		if ( TChar::IsLowSurrogate( *current_character ) )
 			{
 			// skip it
 			RDebug::Print(_L("Error: Should not be low surrogate. Skip corrupt low surrogate %X."), *current_character);
@@ -118,21 +99,21 @@
 		const TText *previous_character = current_character;
 		TUint character_to_process = *current_character++;
 		// If it's surrogate, join the high and low together
-		if( IsHighSurrogate( character_to_process ) )
+		if( TChar::IsHighSurrogate( character_to_process ) )
 			{
 			TInt high = character_to_process;
 			if ( current_character < last_character )
 			    {
 	            TInt low = *current_character++;
-	            if ( !IsLowSurrogate( low ) )
+	            if ( !TChar::IsLowSurrogate( low ) )
 	                {
 	                // should be low surrogate
 	                // skip the high surrogate
-	                RDebug::Print(_L("Error: Should be low surrogate. Skip corrupt high surrogate %X."), high);
+	                RDebug::Print(_L("Error: %X should be low surrogate. Skip corrupt high surrogate %X."), low, high);
 	                current_character--;
 	                continue;
 	                }
-	            character_to_process = JoinSurrogates( high, low );			    
+	            character_to_process = TChar::JoinSurrogate( high, low );			    
 			    }
 			}
 
@@ -217,23 +198,23 @@
 				{
 				TUint next_character_to_process = *current_character;
 				// If the next character is surrogate
-		        if( IsHighSurrogate( next_character_to_process ) )
+		        if( TChar::IsHighSurrogate( next_character_to_process ) )
 		            {
 		            TInt high = next_character_to_process;
 		            if ( current_character < last_character )
 		                {
 	                    TInt low = *(++current_character);
 	                    
-	                    if ( !IsLowSurrogate( low ) )
+	                    if ( !TChar::IsLowSurrogate( low ) )
 	                        {
 	                        // should be low surrogate
-	                        RDebug::Print(_L("Error: Should be low surrogate. See TmChunk.cpp, TruncateIfNeeded()."));
+	                        RDebug::Print(_L("Error: %X should be low surrogate. See TmChunk.cpp, TruncateIfNeeded()."), low);
                             // The category of the character is determined by what it's mapped
 	                        next_character_to_process = aContext.iSource.Map( high );
 	                        }
 	                    else
 	                        {
-	                        next_character_to_process = JoinSurrogates( high, low );
+	                        next_character_to_process = TChar::JoinSurrogate( high, low );
 	                        }
 	                    --current_character;		                
 		                }