sl@0: /* sl@0: * Copyright (c) 1997-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: #include "featmgr/featmgr.h" sl@0: sl@0: _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a"); sl@0: _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42"); sl@0: _LIT8(KLit8EscapeSequenceForHalfWidthKatakana, "\x1b\x28\x49"); sl@0: _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42"); sl@0: _LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44"); sl@0: _LIT8(KLit8JisReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark sl@0: sl@0: class CJISConverterImpl : 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 CJISConverterImpl* NewL(); sl@0: virtual ~CJISConverterImpl(); sl@0: sl@0: private: sl@0: CJISConverterImpl(); sl@0: void ConstructL(); sl@0: sl@0: }; sl@0: sl@0: sl@0: sl@0: const TDesC8& CJISConverterImpl::ReplacementForUnconvertibleUnicodeCharacters() sl@0: { sl@0: return KLit8JisReplacementForUnconvertibleUnicodeCharacters; 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 ConvertFromHalfWidthKatakanaToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) sl@0: { sl@0: CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForHalfWidthKatakana, 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 CJISConverterImpl::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=&CnvJisBase::HalfWidthKatakana7ConversionData(); sl@0: characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakanaToJisInPlace; sl@0: characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForHalfWidthKatakana; sl@0: characterSets[3].iConversionData=&CnvJisX0208::ConversionData(); sl@0: characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace; sl@0: characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983; sl@0: characterSets[4].iConversionData=&CnvJisX0212::ConversionData(); sl@0: characterSets[4].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace; sl@0: characterSets[4].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990; sl@0: return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array()); sl@0: } sl@0: sl@0: TInt CJISConverterImpl::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 CJISConverterImpl::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: CJISConverterImpl* CJISConverterImpl::NewL() sl@0: { sl@0: CJISConverterImpl* self = new(ELeave) CJISConverterImpl(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CJISConverterImpl::~CJISConverterImpl() sl@0: { sl@0: FeatureManager::UnInitializeLib(); sl@0: } sl@0: sl@0: CJISConverterImpl::CJISConverterImpl() sl@0: { sl@0: } sl@0: sl@0: void CJISConverterImpl::ConstructL() sl@0: { sl@0: FeatureManager::InitializeLibL(); sl@0: } sl@0: sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(0x10006066, CJISConverterImpl::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: