Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "PictographObserver.h"
19 #include "featmgr/featmgr.h"
23 #include <convutils.h>
28 #include <ecom/implementationproxy.h>
29 #include "charactersetconverter.h"
31 _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
32 _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
33 //_LIT8(KLit8EscapeSequenceForJisC6226_1978, "\x1b\x24\x40");
34 _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
35 _LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44");
36 //_LIT8(KLit8EscapeSequenceForHalfWidthKatakana, "\x1b\x28\x49");
37 _LIT8(KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
40 class CISO2022JP1ConverterImpl : public CCharacterSetConverterPluginInterface
44 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
46 virtual TInt ConvertFromUnicode(
47 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
48 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
50 const TDesC16& aUnicode,
51 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
53 virtual TInt ConvertToUnicode(
54 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
56 const TDesC8& aForeign,
58 TInt& aNumberOfUnconvertibleCharacters,
59 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
61 virtual TBool IsInThisCharacterSetL(
63 TInt& aConfidenceLevel,
64 const TDesC8& aSample);
66 static CISO2022JP1ConverterImpl* NewL();
67 virtual ~CISO2022JP1ConverterImpl();
70 CISO2022JP1ConverterImpl();
76 const TDesC8& CISO2022JP1ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
78 return KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters;
81 LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
83 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
86 LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
88 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
91 LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
93 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
96 LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
98 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2);
101 TInt CISO2022JP1ConverterImpl::ConvertFromUnicode(
102 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
103 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
105 const TDesC16& aUnicode,
106 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
109 RArray<CnvUtilities::SCharacterSet> characterSets;
110 if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
112 CnvUtilities::SCharacterSet characterSet;
113 characterSet.iConversionData=&CnvJisRoman::ConversionData();
114 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
115 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
116 ret |= characterSets.Append(characterSet);
117 characterSet.iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
118 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
119 characterSet.iEscapeSequence=&KLit8EscapeSequenceForAscii;
120 ret |= characterSets.Append(characterSet);
121 characterSet.iConversionData=&CnvJisX0208::ConversionData();
122 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
123 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
124 ret |= characterSets.Append(characterSet);
125 characterSet.iConversionData=&CnvJisX0212::ConversionData();
126 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
127 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
128 ret |= characterSets.Append(characterSet);
130 SetCharacterSetsForPictograph(characterSets);
134 CnvUtilities::SCharacterSet characterSet;
135 characterSet.iConversionData=&CnvJisRoman::ConversionData();
136 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
137 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
138 ret |= characterSets.Append(characterSet);
139 characterSet.iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
140 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
141 characterSet.iEscapeSequence=&KLit8EscapeSequenceForAscii;
142 ret |= characterSets.Append(characterSet);
143 characterSet.iConversionData=&CnvJisX0208::ConversionData();
144 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
145 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
146 ret |= characterSets.Append(characterSet);
147 characterSet.iConversionData=&CnvJisX0212::ConversionData();
148 characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
149 characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
150 ret |= characterSets.Append(characterSet);
152 __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret));
154 TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet;
155 TInt unconvert = CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters,
156 characterSets.Array(),notUsed,inputConversionFlags);
158 characterSets.Close();
162 TInt CISO2022JP1ConverterImpl::ConvertToUnicode(
163 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
165 const TDesC8& aForeign,
167 TInt& aNumberOfUnconvertibleCharacters,
168 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
170 return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
173 TBool CISO2022JP1ConverterImpl::IsInThisCharacterSetL(
175 TInt& aConfidenceLevel,
176 const TDesC8& aSample)
179 CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
183 CISO2022JP1ConverterImpl* CISO2022JP1ConverterImpl::NewL()
185 CISO2022JP1ConverterImpl* self = new(ELeave) CISO2022JP1ConverterImpl();
186 CleanupStack::PushL(self);
188 CleanupStack::Pop(self);
192 CISO2022JP1ConverterImpl::~CISO2022JP1ConverterImpl()
194 FeatureManager::UnInitializeLib();
197 CISO2022JP1ConverterImpl::CISO2022JP1ConverterImpl()
201 void CISO2022JP1ConverterImpl::ConstructL()
203 FeatureManager::InitializeLibL();
206 const TImplementationProxy ImplementationTable[] =
209 IMPLEMENTATION_PROXY_ENTRY(0x01000009, CISO2022JP1ConverterImpl::NewL)
211 IMPLEMENTATION_PROXY_ENTRY(0x100066A3, CISO2022JP1ConverterImpl::NewL)
215 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
217 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
219 return ImplementationTable;