sl@0: /* sl@0: * Copyright (c) 2000-2009 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: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "jisbase.h" sl@0: #include "jisx0201.h" sl@0: #include "jisx0208.h" sl@0: #include "jisx0212.h" sl@0: #include sl@0: #include sl@0: sl@0: _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a"); sl@0: _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42"); sl@0: _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42"); sl@0: _LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44"); sl@0: _LIT8(KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark sl@0: sl@0: sl@0: class CISO2022JP1ConverterImpl : public CCharacterSetConverterPluginInterface sl@0: { sl@0: sl@0: public: sl@0: virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters(); sl@0: sl@0: virtual TInt ConvertFromUnicode( sl@0: CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, sl@0: const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, sl@0: TDes8& aForeign, sl@0: const TDesC16& aUnicode, sl@0: CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters); sl@0: sl@0: virtual TInt ConvertToUnicode( sl@0: CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, sl@0: TDes16& aUnicode, sl@0: const TDesC8& aForeign, sl@0: TInt& aState, sl@0: TInt& aNumberOfUnconvertibleCharacters, sl@0: TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter); sl@0: sl@0: virtual TBool IsInThisCharacterSetL( sl@0: TBool& aSetToTrue, sl@0: TInt& aConfidenceLevel, sl@0: const TDesC8& aSample); sl@0: sl@0: static CISO2022JP1ConverterImpl* NewL(); sl@0: virtual ~CISO2022JP1ConverterImpl(); sl@0: sl@0: private: sl@0: CISO2022JP1ConverterImpl(); sl@0: sl@0: }; sl@0: sl@0: sl@0: const TDesC8& CISO2022JP1ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters() sl@0: { sl@0: return KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters; sl@0: } sl@0: sl@0: LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1); sl@0: } sl@0: sl@0: LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1); sl@0: } sl@0: sl@0: LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2); sl@0: } sl@0: sl@0: LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2); sl@0: } sl@0: sl@0: TInt CISO2022JP1ConverterImpl::ConvertFromUnicode( sl@0: CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, sl@0: const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, sl@0: TDes8& aForeign, sl@0: const TDesC16& aUnicode, sl@0: CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters) sl@0: { sl@0: TFixedArray characterSets; sl@0: characterSets[0].iConversionData=&CnvJisRoman::ConversionData(); sl@0: characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace; sl@0: characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForJisRoman; sl@0: characterSets[1].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData(); sl@0: characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace; sl@0: characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForAscii; sl@0: characterSets[2].iConversionData=&CnvJisX0208::ConversionData(); sl@0: characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace; sl@0: characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983; sl@0: characterSets[3].iConversionData=&CnvJisX0212::ConversionData(); sl@0: characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace; sl@0: characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990; sl@0: TUint notUsed; sl@0: TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet; sl@0: return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array(),notUsed,inputConversionFlags); sl@0: } sl@0: sl@0: TInt CISO2022JP1ConverterImpl::ConvertToUnicode( sl@0: CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, sl@0: TDes16& aUnicode, sl@0: const TDesC8& aForeign, sl@0: TInt& aState, sl@0: TInt& aNumberOfUnconvertibleCharacters, sl@0: TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter) sl@0: { sl@0: return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter); sl@0: } sl@0: sl@0: TBool CISO2022JP1ConverterImpl::IsInThisCharacterSetL( sl@0: TBool& aSetToTrue, sl@0: TInt& aConfidenceLevel, sl@0: const TDesC8& aSample) sl@0: { sl@0: aSetToTrue=ETrue; sl@0: CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample); sl@0: return ETrue; sl@0: } sl@0: sl@0: CISO2022JP1ConverterImpl* CISO2022JP1ConverterImpl::NewL() sl@0: { sl@0: CISO2022JP1ConverterImpl* self = new(ELeave) CISO2022JP1ConverterImpl(); sl@0: return self; sl@0: } sl@0: sl@0: CISO2022JP1ConverterImpl::~CISO2022JP1ConverterImpl() sl@0: { sl@0: } sl@0: sl@0: CISO2022JP1ConverterImpl::CISO2022JP1ConverterImpl() sl@0: { sl@0: } sl@0: sl@0: sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(0x100066A3, CISO2022JP1ConverterImpl::NewL) sl@0: }; sl@0: sl@0: EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) sl@0: { sl@0: aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); sl@0: sl@0: return ImplementationTable; sl@0: } sl@0: