Update contrib.
2 * Copyright (c) 1997-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.
21 #include <convutils.h>
26 #include <ecom/implementationproxy.h>
27 #include <charactersetconverter.h>
28 #include "featmgr/featmgr.h"
30 _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
31 _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
32 _LIT8(KLit8EscapeSequenceForHalfWidthKatakana, "\x1b\x28\x49");
33 _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
34 _LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44");
35 _LIT8(KLit8JisReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
37 class CJISConverterImpl : public CCharacterSetConverterPluginInterface
41 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
43 virtual TInt ConvertFromUnicode(
44 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
45 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
47 const TDesC16& aUnicode,
48 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
50 virtual TInt ConvertToUnicode(
51 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
53 const TDesC8& aForeign,
55 TInt& aNumberOfUnconvertibleCharacters,
56 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
58 virtual TBool IsInThisCharacterSetL(
60 TInt& aConfidenceLevel,
61 const TDesC8& aSample);
63 static CJISConverterImpl* NewL();
64 virtual ~CJISConverterImpl();
74 const TDesC8& CJISConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
76 return KLit8JisReplacementForUnconvertibleUnicodeCharacters;
79 LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
81 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
84 LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
86 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
89 LOCAL_C void ConvertFromHalfWidthKatakanaToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
91 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForHalfWidthKatakana, 1);
94 LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
96 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
99 LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
101 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2);
104 TInt CJISConverterImpl::ConvertFromUnicode(
105 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
106 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
108 const TDesC16& aUnicode,
109 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
111 TFixedArray<CnvUtilities::SCharacterSet, 5> characterSets;
112 characterSets[0].iConversionData=&CnvJisRoman::ConversionData();
113 characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
114 characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
115 characterSets[1].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
116 characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
117 characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForAscii;
118 characterSets[2].iConversionData=&CnvJisBase::HalfWidthKatakana7ConversionData();
119 characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakanaToJisInPlace;
120 characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForHalfWidthKatakana;
121 characterSets[3].iConversionData=&CnvJisX0208::ConversionData();
122 characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
123 characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
124 characterSets[4].iConversionData=&CnvJisX0212::ConversionData();
125 characterSets[4].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
126 characterSets[4].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
127 return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array());
130 TInt CJISConverterImpl::ConvertToUnicode(
131 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
133 const TDesC8& aForeign,
135 TInt& aNumberOfUnconvertibleCharacters,
136 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
138 return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
141 TBool CJISConverterImpl::IsInThisCharacterSetL(
143 TInt& aConfidenceLevel,
144 const TDesC8& aSample)
147 CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
151 CJISConverterImpl* CJISConverterImpl::NewL()
153 CJISConverterImpl* self = new(ELeave) CJISConverterImpl();
154 CleanupStack::PushL(self);
156 CleanupStack::Pop(self);
160 CJISConverterImpl::~CJISConverterImpl()
162 FeatureManager::UnInitializeLib();
165 CJISConverterImpl::CJISConverterImpl()
169 void CJISConverterImpl::ConstructL()
171 FeatureManager::InitializeLibL();
174 const TImplementationProxy ImplementationTable[] =
176 IMPLEMENTATION_PROXY_ENTRY(0x10006066, CJISConverterImpl::NewL)
179 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
181 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
183 return ImplementationTable;