kernel/eka/common/des16.cpp
changeset 259 57b9594f5772
parent 90 947f0dc9f7a8
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
  1689 @see TDesC16::LocateReverseF()
  1689 @see TDesC16::LocateReverseF()
  1690 */
  1690 */
  1691 	{
  1691 	{
  1692 	TInt strLength = Length();
  1692 	TInt strLength = Length();
  1693 	const TText16* start = Ptr();
  1693 	const TText16* start = Ptr();
  1694 	const TText16* end = Ptr() + strLength;
       
  1695 	TText16* newEnd;
  1694 	TText16* newEnd;
  1696 	TUint currentChar;
  1695 	TUint currentChar;
  1697 	TInt int16Index = 0;
  1696 	TInt int16Index = strLength;
  1698 	TInt status = KErrNone;
  1697 	TInt status = KErrNone;
  1699 	FOREVER
  1698 	FOREVER
  1700 		{
  1699 		{
  1701 		status = ::RecedeOneCharacter(start, end, newEnd, currentChar);
  1700 		status = ::RecedeOneCharacter(start, start+int16Index, newEnd, currentChar);
  1702         if (status != KErrNone)
  1701 		if (status != KErrNone)
  1703             return status;
  1702 		    return status;
       
  1703 		int16Index = (newEnd - start);
  1704 		TCharF c(currentChar);
  1704 		TCharF c(currentChar);
  1705 		if (c == aChar)
  1705 		if (c == aChar)
  1706 			return int16Index;
  1706 		    return int16Index;
  1707 		int16Index = (newEnd - start);
       
  1708 		}
  1707 		}
  1709 	}
  1708 	}
  1710 
  1709 
  1711 inline TUint conv2(TUint aChar, const TText *aConv, const TUnicodeDataSet* aCharDataSet)
  1710 inline TUint conv2(TUint aChar, const TText *aConv, const TUnicodeDataSet* aCharDataSet)
  1712 // Surrogate-aware version of conv().
  1711 // Surrogate-aware version of conv().
  3988 existing data.
  3987 existing data.
  3989 
  3988 
  3990 The descriptor is filled from the beginning up to its current length. The 
  3989 The descriptor is filled from the beginning up to its current length. The 
  3991 descriptor's length does not change. It is not filled to its maximum length.
  3990 descriptor's length does not change. It is not filled to its maximum length.
  3992 If aChar is supplementary character, and available space to fill is odd in
  3991 If aChar is supplementary character, and available space to fill is odd in
  3993 16-bit unit, then the last 16-bit unit will be left unchanged, and the length
  3992 16-bit unit, then the last 16-bit unit will be filled with high surrogate, 
  3994 will keep unchanged.
  3993 and the length will keep unchanged.
  3995 
  3994 
  3996 @param aChar The fill character. Can be inside or outside BMP.
  3995 @param aChar The fill character. Can be inside or outside BMP.
  3997 
  3996 
  3998 @see TDes16::Fill()
  3997 @see TDes16::Fill()
  3999 */
  3998 */
  4010 		while (pB < pE - 1)
  4009 		while (pB < pE - 1)
  4011 			{
  4010 			{
  4012 			*pB++ = TChar::GetHighSurrogate(aChar);
  4011 			*pB++ = TChar::GetHighSurrogate(aChar);
  4013 			*pB++ = TChar::GetLowSurrogate(aChar);
  4012 			*pB++ = TChar::GetLowSurrogate(aChar);
  4014 			}
  4013 			}
       
  4014 		// fill the last 16-bit unit
       
  4015 		if (pB < pE)
       
  4016 		    *pB++ = TChar::GetHighSurrogate(aChar);
  4015 		}
  4017 		}
  4016 	}
  4018 	}
  4017 
  4019 
  4018 EXPORT_C void TDes16::Fill2(TChar aChar, TInt aLength)
  4020 EXPORT_C void TDes16::Fill2(TChar aChar, TInt aLength)
  4019 /**
  4021 /**
  4054 
  4056 
  4055 The descriptor is appended with the specified number of characters, and its
  4057 The descriptor is appended with the specified number of characters, and its
  4056 length is changed to reflect this.
  4058 length is changed to reflect this.
  4057 
  4059 
  4058 If aChar is supplementary character, and available space to fill is odd in 
  4060 If aChar is supplementary character, and available space to fill is odd in 
  4059 16-bit unit, then the last 16-bit unit will be left unchanged.
  4061 16-bit unit, then the last 16-bit unit will be filled with high surrogate.
  4060 
  4062 
  4061 @param aChar   The fill character. Can be inside or outside BMP.
  4063 @param aChar   The fill character. Can be inside or outside BMP.
  4062 @param aLength The length of additional space to append into.
  4064 @param aLength The length of additional space to append into.
  4063 
  4065 
  4064 @panic USER 11  if aLength is negative, or the resulting length of this
  4066 @panic USER 11  if aLength is negative, or the resulting length of this
  4086 		while (pB < pE - 1)
  4088 		while (pB < pE - 1)
  4087 			{
  4089 			{
  4088 			*pB++ = TChar::GetHighSurrogate(aChar);
  4090 			*pB++ = TChar::GetHighSurrogate(aChar);
  4089 			*pB++ = TChar::GetLowSurrogate(aChar);
  4091 			*pB++ = TChar::GetLowSurrogate(aChar);
  4090 			}
  4092 			}
       
  4093         // fill the last 16-bit unit
       
  4094         if (pB < pE)
       
  4095             *pB++ = TChar::GetHighSurrogate(aChar);
  4091 		}
  4096 		}
  4092 	}
  4097 	}
  4093 
  4098 
  4094 EXPORT_C void TDes16::Justify2(const TDesC16 &aDes, TInt aWidth, TAlign anAlignment, TChar aFill)
  4099 EXPORT_C void TDes16::Justify2(const TDesC16 &aDes, TInt aWidth, TAlign anAlignment, TChar aFill)
  4095 /**
  4100 /**