First public contribution.
2 * Copyright (c) 2000-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>
29 _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
30 _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
31 _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
32 _LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44");
33 _LIT8(KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
36 class CISO2022JP1ConverterImpl : public CCharacterSetConverterPluginInterface
40 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
42 virtual TInt ConvertFromUnicode(
43 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
44 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
46 const TDesC16& aUnicode,
47 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
49 virtual TInt ConvertToUnicode(
50 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
52 const TDesC8& aForeign,
54 TInt& aNumberOfUnconvertibleCharacters,
55 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
57 virtual TBool IsInThisCharacterSetL(
59 TInt& aConfidenceLevel,
60 const TDesC8& aSample);
62 static CISO2022JP1ConverterImpl* NewL();
63 virtual ~CISO2022JP1ConverterImpl();
66 CISO2022JP1ConverterImpl();
71 const TDesC8& CISO2022JP1ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
73 return KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters;
76 LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
78 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
81 LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
83 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
86 LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
88 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
91 LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
93 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2);
96 TInt CISO2022JP1ConverterImpl::ConvertFromUnicode(
97 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
98 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
100 const TDesC16& aUnicode,
101 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
103 TFixedArray<CnvUtilities::SCharacterSet, 4> characterSets;
104 characterSets[0].iConversionData=&CnvJisRoman::ConversionData();
105 characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
106 characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
107 characterSets[1].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
108 characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
109 characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForAscii;
110 characterSets[2].iConversionData=&CnvJisX0208::ConversionData();
111 characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
112 characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
113 characterSets[3].iConversionData=&CnvJisX0212::ConversionData();
114 characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
115 characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
117 TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet;
118 return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array(),notUsed,inputConversionFlags);
121 TInt CISO2022JP1ConverterImpl::ConvertToUnicode(
122 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
124 const TDesC8& aForeign,
126 TInt& aNumberOfUnconvertibleCharacters,
127 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
129 return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
132 TBool CISO2022JP1ConverterImpl::IsInThisCharacterSetL(
134 TInt& aConfidenceLevel,
135 const TDesC8& aSample)
138 CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
142 CISO2022JP1ConverterImpl* CISO2022JP1ConverterImpl::NewL()
144 CISO2022JP1ConverterImpl* self = new(ELeave) CISO2022JP1ConverterImpl();
148 CISO2022JP1ConverterImpl::~CISO2022JP1ConverterImpl()
152 CISO2022JP1ConverterImpl::CISO2022JP1ConverterImpl()
157 const TImplementationProxy ImplementationTable[] =
159 IMPLEMENTATION_PROXY_ENTRY(0x100066A3, CISO2022JP1ConverterImpl::NewL)
162 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
164 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
166 return ImplementationTable;