sl@0: /* sl@0: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: This class is a utitlity class for conversion of Vodafone sl@0: * pictograph. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: // PICTOGRAPH_SHARED.CPP sl@0: // sl@0: // sl@0: sl@0: #include "CnvPictographShared.h" sl@0: // #include "CnvPictograph1.h" sl@0: #include "CnvShiftJisDirectmap.h" sl@0: #include sl@0: sl@0: sl@0: // CONSTANTS sl@0: // Escape sequence for Vodafone pictograph sl@0: _LIT8(KLit8EscapeSequenceForPictograph, "\x1b\x24"); sl@0: // _LIT8(KLit8EscapeSequenceForPictograph1, "\x1b\x24\x47"); sl@0: sl@0: const TInt KEscape = 0x1B; sl@0: const TInt KShiftIn = 0x0F; sl@0: sl@0: // Intermidiate buffers for pictograph sl@0: const TInt KIntermediateBuffer1 = 'G'; sl@0: sl@0: const TUint KSingleByteRangeFirstBlockStart = 0xF0; sl@0: const TUint KSingleByteRangeFirstBlockEnd = 0xF9; sl@0: const TUint KSingleByteRangeSecondBlockStart = 0x40; sl@0: const TUint KSingleByteRangeSecondBlockEnd = 0xFC; sl@0: sl@0: const TUint KFirstByteRangeFirstBlockStart = 0xF5; sl@0: const TUint KFirstByteRangeFirstBlockEnd = 0xFE; sl@0: const TUint KSecondByteRangeSecondBlockStart = 0xA1; sl@0: const TUint KSecondByteRangeSecondBlockEnd = 0xFE; sl@0: sl@0: const TUint KEUCJPSecondBlockStart = 0xF5; sl@0: const TUint KEUCJPBlockSize = 0x5D; sl@0: const TUint KSingleShift3=0x8f; sl@0: // used for EucJp sl@0: const TUint KPictographStartFirstByte = 0xF0; sl@0: const TUint KPictographStartSecondByte = 0x40; sl@0: const TUint KShiftJisTrailByteIllegal = 0x7F; sl@0: sl@0: // ============================ LOCAL FUNCTIONS =============================== sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // DummyConvertToIntermediateBufferInPlace ?description. sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: LOCAL_C void DummyConvertToIntermediateBufferInPlace(TDes8&) sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // DummyConvertFromIntermediateBufferInPlace sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: LOCAL_C void DummyConvertFromIntermediateBufferInPlace(TInt, TDes8&, sl@0: TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: aNumberOfCharactersThatDroppedOut=0; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // ConvertFromPictogaphToEucJpDirectmapInPlace sl@0: // Converts from EucJp packed Pictograph to Unicode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: LOCAL_C void ConvertFromPictogaphToEucJpDirectmapInPlace( sl@0: TInt aStartPositionInDescriptor, TDes8& aDescriptor, sl@0: TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: TInt descriptorLength=aDescriptor.Length(); sl@0: TInt bytesPerCharacter = 2; sl@0: if (aDescriptor[0] >= KEUCJPSecondBlockStart) sl@0: { sl@0: bytesPerCharacter = 3; sl@0: } sl@0: sl@0: aNumberOfCharactersThatDroppedOut = sl@0: Max(0, ((descriptorLength - aStartPositionInDescriptor) / 2) - sl@0: ((aDescriptor.MaxLength() - aStartPositionInDescriptor) / sl@0: bytesPerCharacter)); sl@0: descriptorLength -= aNumberOfCharactersThatDroppedOut * 2; sl@0: if (descriptorLength <= aStartPositionInDescriptor) sl@0: { sl@0: aDescriptor.SetLength(descriptorLength); sl@0: } sl@0: else sl@0: { sl@0: // pointerToTargetByte is initialized properly when descriptorLength sl@0: // has been offset to the actual final length of aDescriptor sl@0: TUint8* pointerToTargetByte = CONST_CAST(TUint8*, aDescriptor.Ptr()); sl@0: const TUint8* const pointerToFirstByte = sl@0: pointerToTargetByte + aStartPositionInDescriptor; sl@0: const TUint8* pointerToSourceByte = sl@0: pointerToTargetByte + (descriptorLength - 1); sl@0: descriptorLength = (((descriptorLength - aStartPositionInDescriptor) sl@0: * bytesPerCharacter) / 2) + aStartPositionInDescriptor; sl@0: aDescriptor.SetLength(descriptorLength); sl@0: // pointerToTargetByte is is initialized properly here sl@0: pointerToTargetByte += descriptorLength - 1; sl@0: for (;pointerToTargetByte > pointerToFirstByte; ) sl@0: { sl@0: TInt secondByte = *pointerToSourceByte; sl@0: TInt firstByte = *(pointerToSourceByte - 1); sl@0: sl@0: if (bytesPerCharacter == 3) sl@0: { sl@0: firstByte = (firstByte - KEUCJPSecondBlockStart) * 2 + sl@0: KFirstByteRangeFirstBlockStart; sl@0: } sl@0: else sl@0: { sl@0: firstByte = (firstByte - KPictographStartFirstByte) * 2 + sl@0: KFirstByteRangeFirstBlockStart; sl@0: } sl@0: if (static_cast(KEUCJPBlockSize + KPictographStartSecondByte + 1) sl@0: < secondByte) sl@0: { sl@0: if (secondByte > KShiftJisTrailByteIllegal) sl@0: secondByte -= 1; sl@0: secondByte = secondByte -(KPictographStartSecondByte + sl@0: KEUCJPBlockSize + 1) + KSecondByteRangeSecondBlockStart; sl@0: firstByte++; sl@0: } sl@0: else sl@0: { sl@0: if (secondByte > KShiftJisTrailByteIllegal) sl@0: secondByte -= 1; sl@0: secondByte += KSecondByteRangeSecondBlockStart - KPictographStartSecondByte; sl@0: } sl@0: *pointerToTargetByte = static_cast(secondByte); sl@0: --pointerToTargetByte; sl@0: *pointerToTargetByte = static_cast(firstByte); sl@0: if (bytesPerCharacter == 3) sl@0: { sl@0: --pointerToTargetByte; sl@0: *pointerToTargetByte = KSingleShift3; sl@0: } sl@0: --pointerToTargetByte; sl@0: pointerToSourceByte -= 2; sl@0: } sl@0: } sl@0: } sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::SetCharacterSetsForPictograph sl@0: // It sets parameters to SCharacterSet array. It called in ConvertFromUnicode(). sl@0: // It makes possible that pictograph conversion is called from other conversion sl@0: // plug-ins. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::SetCharacterSetsForPictograph( sl@0: RArray& /*aArrayOfCharacterSets*/) sl@0: { sl@0: // SAMPLE CODE sl@0: // If this module needs to support escape sequence pictograph, sl@0: // Remove the comment from the following code. sl@0: sl@0: // CnvUtilities::SCharacterSet characterSet; sl@0: // characterSet.iConversionData = &CnvPictograph1::ConversionData(); sl@0: // characterSet.iConvertFromIntermediateBufferInPlace = sl@0: // CnvPictographShared::ConvertToPictograph1InPlace; sl@0: // characterSet.iEscapeSequence = &KLit8EscapeSequenceForPictograph1; sl@0: // aArrayOfCharacterSets.Append(characterSet); sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::SetMethodsForPictograph sl@0: // It sets parameters to SMethod array. It called in ConvertToUnicode(). sl@0: // It makes possible that pictograph conversion is called from other conversion sl@0: // plug-ins. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::SetMethodsForPictograph( sl@0: RArray& aArrayOfMethods, TOriginalCharset aOriginalCharset) sl@0: { sl@0: TInt ret = KErrNone; sl@0: CnvUtilities::SMethod method; sl@0: switch (aOriginalCharset) sl@0: { sl@0: case ECharsetShiftJis: sl@0: method.iNumberOfBytesAbleToConvert = sl@0: CnvPictographShared::NumberOfBytesAbleToConvertSJisDirectMap; sl@0: method.iConvertToIntermediateBufferInPlace = sl@0: DummyConvertToIntermediateBufferInPlace; sl@0: method.iConversionData = sl@0: &CnvShiftJisDirectmap::ConversionData(); sl@0: method.iNumberOfBytesPerCharacter = 2; sl@0: method.iNumberOfCoreBytesPerCharacter = 2; sl@0: ret |= aArrayOfMethods.Append(method); sl@0: break; sl@0: case ECharsetEucJp: sl@0: method.iNumberOfBytesAbleToConvert = sl@0: CnvPictographShared::NumberOfBytesAbleToConvertToEucJpDirectMap1; sl@0: method.iConvertToIntermediateBufferInPlace = sl@0: CnvPictographShared::ConvertToPictographFromEucJpPackedInPlace; sl@0: method.iConversionData = sl@0: &CnvShiftJisDirectmap::ConversionData(); sl@0: method.iNumberOfBytesPerCharacter = 2; sl@0: method.iNumberOfCoreBytesPerCharacter = 2; sl@0: ret |= aArrayOfMethods.Append(method); sl@0: method.iNumberOfBytesAbleToConvert = sl@0: CnvPictographShared::NumberOfBytesAbleToConvertToEucJpDirectMap2; sl@0: method.iConvertToIntermediateBufferInPlace = sl@0: CnvPictographShared::ConvertToPictographFromEucJpPackedInPlace; sl@0: method.iConversionData = sl@0: &CnvShiftJisDirectmap::ConversionData(); sl@0: method.iNumberOfBytesPerCharacter = 3; sl@0: method.iNumberOfCoreBytesPerCharacter = 2; sl@0: ret |= aArrayOfMethods.Append(method); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret)); sl@0: // SAMPLE CODE sl@0: // If this module needs to support escape sequence pictograph, sl@0: // Remove the comment from the following code. sl@0: sl@0: // method.iNumberOfBytesAbleToConvert = sl@0: // CnvPictographShared::NumberOfBytesAbleToConvertToPicto1; sl@0: // method.iConvertToIntermediateBufferInPlace = sl@0: // CnvPictographShared::ConvertToPictographFromUnicode; sl@0: // method.iConversionData = &CnvPictograph1::ConversionData(); sl@0: // method.iNumberOfBytesPerCharacter = 1; sl@0: // method.iNumberOfCoreBytesPerCharacter = 1; sl@0: // aArrayOfMethods.Append(method); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::SetCharacterSetsForPictograph sl@0: // It sets parameters to SState array. It called in ConvertToUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::SetCharacterSetsForPictograph( sl@0: RArray& aArrayOfStates, sl@0: TOriginalCharset aOriginalCharset) sl@0: { sl@0: TInt ret = KErrNone; sl@0: CnvUtilities::SCharacterSet characterSet; sl@0: switch (aOriginalCharset) sl@0: { sl@0: case ECharsetShiftJis: sl@0: // Append the character set for pictograph sl@0: characterSet.iConversionData = sl@0: &CnvShiftJisDirectmap::ConversionData(); sl@0: characterSet.iConvertFromIntermediateBufferInPlace = sl@0: DummyConvertFromIntermediateBufferInPlace; sl@0: characterSet.iEscapeSequence = &KNullDesC8; sl@0: ret |= aArrayOfStates.Append(characterSet); sl@0: break; sl@0: case ECharsetEucJp: sl@0: // Append the character set for pictograph1 sl@0: characterSet.iConversionData = &CnvShiftJisDirectmap::ConversionData(); sl@0: characterSet.iConvertFromIntermediateBufferInPlace = sl@0: ConvertFromPictogaphToEucJpDirectmapInPlace; sl@0: characterSet.iEscapeSequence = &KNullDesC8; sl@0: ret |= aArrayOfStates.Append(characterSet); sl@0: sl@0: // Append the character set for pictograph2 sl@0: characterSet.iConversionData = &CnvShiftJisDirectmap::ConversionData(); sl@0: characterSet.iConvertFromIntermediateBufferInPlace = sl@0: ConvertFromPictogaphToEucJpDirectmapInPlace; sl@0: characterSet.iEscapeSequence = &KNullDesC8; sl@0: ret |= aArrayOfStates.Append(characterSet); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret)); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::SetStatesForPictograph sl@0: // It sets parameters to SState array. It called in ConvertToUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::SetStatesForPictograph( sl@0: RArray& /*aArrayOfStates*/) sl@0: { sl@0: // SAMPLE CODE sl@0: // If this module needs to support escape sequence pictograph, sl@0: // Remove the comment from the following code. sl@0: sl@0: // CnvUtilities::SState state; sl@0: // state.iEscapeSequence = &KLit8EscapeSequenceForPictograph1; sl@0: // state.iConversionData = &CnvPictograph1::ConversionData(); sl@0: // aArrayOfStates.Append(state); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::ConvertToPictograph1InPlace sl@0: // It converts from an intermediate buffer to a pictograph code. sl@0: // After that, it adds shift-in code(0x0F). sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: // void CnvPictographShared::ConvertToPictograph1InPlace( sl@0: // TInt aStartPositionInDescriptor, sl@0: // TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: // { sl@0: // CnvUtilities::ConvertFromIntermediateBufferInPlace( sl@0: // aStartPositionInDescriptor, aDescriptor, sl@0: // aNumberOfCharactersThatDroppedOut, sl@0: // KLit8EscapeSequenceForPictograph1, 1); sl@0: // AppendShiftIn(aDescriptor, aNumberOfCharactersThatDroppedOut); sl@0: // } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::NumberOfBytesAbleToConvertToPicto1 sl@0: // It returns a number of bytes that the conversion to pictograph is sl@0: // possible in the descriptor. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CnvPictographShared::NumberOfBytesAbleToConvertSJisDirectMap( sl@0: const TDesC8& aDescriptor) sl@0: { sl@0: const TUint8* pointerToPreviousByte = aDescriptor.Ptr()-1; sl@0: const TUint8* const pointerToLastByte = sl@0: pointerToPreviousByte + aDescriptor.Length(); sl@0: if (pointerToPreviousByte == pointerToLastByte) sl@0: { sl@0: return 0; sl@0: } sl@0: for (; pointerToPreviousByte < pointerToLastByte; ) sl@0: { sl@0: const TUint currentByte = *(pointerToPreviousByte + 1); sl@0: const TUint nextByte = *(pointerToPreviousByte + 2); sl@0: if (((currentByte < KSingleByteRangeFirstBlockStart) || sl@0: (currentByte > KSingleByteRangeFirstBlockEnd)) || sl@0: ((nextByte < KSingleByteRangeSecondBlockStart) || sl@0: (nextByte > KSingleByteRangeSecondBlockEnd))) sl@0: { sl@0: break; sl@0: } sl@0: pointerToPreviousByte += 2; sl@0: } sl@0: return (pointerToPreviousByte + 1) - aDescriptor.Ptr(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // NumberOfBytesAbleToConvertToEucJpDirectMap1 sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CnvPictographShared::NumberOfBytesAbleToConvertToEucJpDirectMap1( sl@0: const TDesC8& aDescriptor) sl@0: { sl@0: const TUint8* pointerToPreviousByte = aDescriptor.Ptr() - 1; sl@0: const TUint8* const pointerToLastByte = sl@0: pointerToPreviousByte + aDescriptor.Length(); sl@0: if (pointerToPreviousByte == pointerToLastByte) sl@0: { sl@0: return 0; sl@0: } sl@0: for (;pointerToPreviousByte < pointerToLastByte;) sl@0: { sl@0: TUint currentByte = *(pointerToPreviousByte + 1); sl@0: const TUint nextByte = *(pointerToPreviousByte + 2); sl@0: if (((currentByte < KFirstByteRangeFirstBlockStart) || sl@0: (currentByte > KFirstByteRangeFirstBlockEnd)) || sl@0: ((nextByte < KSecondByteRangeSecondBlockStart) || sl@0: (nextByte > KSecondByteRangeSecondBlockEnd))) sl@0: { sl@0: break; sl@0: } sl@0: pointerToPreviousByte += 2; sl@0: } sl@0: return (pointerToPreviousByte + 1) - aDescriptor.Ptr(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // NumberOfBytesAbleToConvertToPictograph sl@0: // sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CnvPictographShared::NumberOfBytesAbleToConvertToEucJpDirectMap2( sl@0: const TDesC8& aDescriptor) sl@0: { sl@0: const TUint8* pointerToPreviousByte = aDescriptor.Ptr() - 1; sl@0: const TUint8* const pointerToLastByte = sl@0: pointerToPreviousByte + aDescriptor.Length(); sl@0: if (pointerToPreviousByte == pointerToLastByte) sl@0: { sl@0: return 0; sl@0: } sl@0: for (;pointerToPreviousByte < pointerToLastByte;) sl@0: { sl@0: TUint currentByte = *(pointerToPreviousByte + 1); sl@0: if (currentByte == KSingleShift3) sl@0: { sl@0: pointerToPreviousByte++; sl@0: currentByte = *(pointerToPreviousByte + 1); sl@0: } sl@0: else sl@0: { sl@0: break; sl@0: } sl@0: if (currentByte < 0xa0) sl@0: { sl@0: return CCnvCharacterSetConverter::EErrorIllFormedInput; sl@0: } sl@0: const TUint nextByte = *(pointerToPreviousByte + 2); sl@0: if (nextByte < 0xa0) sl@0: { sl@0: return CCnvCharacterSetConverter::EErrorIllFormedInput; sl@0: } sl@0: if (((currentByte < KFirstByteRangeFirstBlockStart) || sl@0: (currentByte > KFirstByteRangeFirstBlockEnd)) || sl@0: ((nextByte < KSecondByteRangeSecondBlockStart) || sl@0: (nextByte > KSecondByteRangeSecondBlockEnd))) sl@0: { sl@0: // return the previous byte to the beginning of loop. sl@0: pointerToPreviousByte--; sl@0: break; sl@0: } sl@0: pointerToPreviousByte += 2; sl@0: } sl@0: return (pointerToPreviousByte + 1) - aDescriptor.Ptr(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::NumberOfBytesAbleToConvertToPicto1 sl@0: // It returns a number of bytes that the conversion to pictograph is sl@0: // possible in the descriptor. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CnvPictographShared::NumberOfBytesAbleToConvertToPicto1( sl@0: const TDesC8& aDescriptor) sl@0: { sl@0: return NumberOfBytesAbleToConvertToPictograph(aDescriptor, sl@0: KIntermediateBuffer1); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::NumberOfBytesAbleToConvertToPictograph sl@0: // It's a common function for checking the number of bytes that the conversion sl@0: // to pictograph sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CnvPictographShared::NumberOfBytesAbleToConvertToPictograph( sl@0: const TDesC8& aDescriptor, TInt aIntermidiateCode) sl@0: { sl@0: TInt compLen(KLit8EscapeSequenceForPictograph().Length()); sl@0: TInt ret(0); sl@0: if (aDescriptor.Left(compLen) == KLit8EscapeSequenceForPictograph) sl@0: { sl@0: const TInt intermidiateBuff = aDescriptor[compLen]; sl@0: if (intermidiateBuff == aIntermidiateCode) sl@0: { sl@0: ret = compLen + 2; sl@0: sl@0: const TInt descriptorLength = aDescriptor.Length(); sl@0: const TUint8* pointerToCurrentByte = aDescriptor.Ptr(); sl@0: const TUint8* pointerToLastByte = pointerToCurrentByte + sl@0: (descriptorLength - 1); sl@0: pointerToCurrentByte += compLen + 2; sl@0: for (; pointerToCurrentByte <= pointerToLastByte; sl@0: pointerToCurrentByte++) sl@0: { sl@0: if (*pointerToCurrentByte == KShiftIn) sl@0: { sl@0: ret++; sl@0: break; sl@0: } sl@0: if (*pointerToCurrentByte == KEscape) sl@0: break; sl@0: ret++; sl@0: } sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::ConvertToPictographFromUnicode sl@0: // It converts the string which includes a pictograph's escape sequence sl@0: // to unicode. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::ConvertToPictographFromUnicode(TDes8& aDescriptor) sl@0: { sl@0: const TInt descriptorLength = aDescriptor.Length(); sl@0: TUint8* pointerToCurrentByte = CONST_CAST(TUint8*, aDescriptor.Ptr()); sl@0: TUint8* pointerToDataByte = pointerToCurrentByte + sl@0: KLit8EscapeSequenceForPictograph().Length(); sl@0: const TUint8* const pointerToLastByte = pointerToCurrentByte + sl@0: (descriptorLength - 1); sl@0: const TUint8* const pointerToFirstByte = pointerToCurrentByte; sl@0: pointerToDataByte++; sl@0: sl@0: for (; pointerToDataByte <= pointerToLastByte; pointerToDataByte++) sl@0: { sl@0: if (*pointerToDataByte != KShiftIn) sl@0: { sl@0: *pointerToCurrentByte = *pointerToDataByte; sl@0: pointerToCurrentByte++; sl@0: } sl@0: } sl@0: aDescriptor.SetLength(pointerToCurrentByte - pointerToFirstByte); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::ConvertToPictographFromEucJpPackedInPlace sl@0: // Converts from EucJp packed Pictograph to Unicode sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::ConvertToPictographFromEucJpPackedInPlace(TDes8& aDescriptor) sl@0: { sl@0: const TInt descriptorLength = aDescriptor.Length(); sl@0: TUint8* pointerToTargetByte = CONST_CAST(TUint8*, aDescriptor.Ptr()); sl@0: const TUint8* pointerToSourceByte = pointerToTargetByte; sl@0: const TUint8* const pointerToLastByte = sl@0: pointerToSourceByte + (descriptorLength - 1); sl@0: TInt bytesPerCharacter = 2; sl@0: TInt sjisStartbyte = KSingleByteRangeFirstBlockStart; sl@0: if (*pointerToSourceByte == KSingleShift3) sl@0: { sl@0: ++pointerToSourceByte; sl@0: bytesPerCharacter = 3; sl@0: sjisStartbyte = KEUCJPSecondBlockStart; sl@0: } sl@0: for (;pointerToSourceByte < pointerToLastByte; ) sl@0: { sl@0: TUint firstByte = (*pointerToSourceByte sl@0: - KFirstByteRangeFirstBlockStart) / 2 + sjisStartbyte; sl@0: TUint secondByte = *(pointerToSourceByte + 1); sl@0: if ((*pointerToSourceByte % 2) == 0) sl@0: { sl@0: secondByte += KSingleByteRangeSecondBlockStart - KSecondByteRangeSecondBlockStart sl@0: + KEUCJPBlockSize + 1; sl@0: if (secondByte >= KShiftJisTrailByteIllegal) sl@0: secondByte++; sl@0: } sl@0: else sl@0: { sl@0: secondByte += KSingleByteRangeSecondBlockStart - KSecondByteRangeSecondBlockStart; sl@0: if (secondByte >= KShiftJisTrailByteIllegal) sl@0: secondByte++; sl@0: } sl@0: *pointerToTargetByte = static_cast(firstByte); sl@0: sl@0: ++pointerToTargetByte; sl@0: *pointerToTargetByte = static_cast(secondByte); sl@0: pointerToSourceByte += 2; sl@0: ++pointerToTargetByte; sl@0: } sl@0: aDescriptor.SetLength((descriptorLength / bytesPerCharacter) * 2); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CnvPictographShared::AppendShiftIn sl@0: // It appends a shift-in code to the descriptor. sl@0: // (other items were commented in a header). sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CnvPictographShared::AppendShiftIn(TDes8& aDescriptor, sl@0: TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: if (aDescriptor.MaxLength() > aDescriptor.Length()) sl@0: { sl@0: aDescriptor.Append(KShiftIn); sl@0: } sl@0: else sl@0: { sl@0: aNumberOfCharactersThatDroppedOut++; sl@0: } sl@0: } sl@0: sl@0: // ========================== OTHER EXPORTED FUNCTIONS ========================= sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // SetCharacterSetsForPictograph() sl@0: // It sets parameters to SCharacterSet array. sl@0: // It called in ConvertFromUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // @since 2.6 sl@0: // @param aArrayOfCharacterSets The conversion table array sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C void SetCharacterSetsForPictograph( sl@0: RArray& aArrayOfCharacterSets) sl@0: { sl@0: CnvPictographShared::SetCharacterSetsForPictograph(aArrayOfCharacterSets); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // SetCharacterSetsForPictograph() sl@0: // It sets parameters to SCharacterSet array. sl@0: // It called in ConvertFromUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // @since 2.6 sl@0: // @param aArrayOfCharacterSets The conversion table array sl@0: // @param aOriginalCharset The character set sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C void SetCharacterSetsForPictograph( sl@0: RArray& aArrayOfCharacterSets, sl@0: TOriginalCharset aOriginalCharset) sl@0: { sl@0: CnvPictographShared::SetCharacterSetsForPictograph(aArrayOfCharacterSets, sl@0: aOriginalCharset); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // SetMethodsForPictograph() sl@0: // It sets parameters to SMethod array. sl@0: // It called in ConvertToUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // @since 2.6 sl@0: // @param aArrayOfMethods The conversion table array sl@0: // @param aOriginalCharset The character set sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C void SetMethodsForPictograph( sl@0: RArray& aArrayOfMethods, sl@0: TOriginalCharset aOriginalCharset) sl@0: { sl@0: CnvPictographShared::SetMethodsForPictograph(aArrayOfMethods, sl@0: aOriginalCharset); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // SetStatesForPictograph() sl@0: // It sets parameters to SState array. sl@0: // It called in ConvertToUnicode(). sl@0: // It makes possible that pictograph conversion is called from other sl@0: // conversion plug-ins. sl@0: // @since 2.6 sl@0: // @param aArrayOfMethods The conversion table array sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C void SetStatesForPictograph( sl@0: RArray& aArrayOfStates) sl@0: { sl@0: CnvPictographShared::SetStatesForPictograph(aArrayOfStates); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CountOfPictographPagesFromUnicode() sl@0: // It returns count of pictograph pages. sl@0: // This method is used for the conversion from Unicode to foreign character sl@0: // set. sl@0: // @since 2.6 sl@0: // @return count of pictograph pages. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CountOfPictographPagesFromUnicode() sl@0: { sl@0: return KCountOfPictoPages; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CountOfPictographPagesToUnicode() sl@0: // It returns count of pictograph pages. sl@0: // This method is used for the conversion from foreign character set to sl@0: // Unicode. sl@0: // @since 2.6 sl@0: // @return count of pictograph pages. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CountOfPictographPagesToUnicode() sl@0: { sl@0: return KCountOfPictoPages + 1; sl@0: } sl@0: sl@0: // End of File