Update contrib.
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>
25 #include <ecom/implementationproxy.h>
26 #include <charactersetconverter.h>
28 _LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
29 _LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
30 _LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
31 _LIT8(KLit8Iso2022JpReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
34 class CISO2022JPConverterImpl : public CCharacterSetConverterPluginInterface
38 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
40 virtual TInt ConvertFromUnicode(
41 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
42 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
44 const TDesC16& aUnicode,
45 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
47 virtual TInt ConvertToUnicode(
48 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
50 const TDesC8& aForeign,
52 TInt& aNumberOfUnconvertibleCharacters,
53 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
55 virtual TBool IsInThisCharacterSetL(
57 TInt& aConfidenceLevel,
58 const TDesC8& aSample);
60 static CISO2022JPConverterImpl* NewL();
61 virtual ~CISO2022JPConverterImpl();
64 CISO2022JPConverterImpl();
70 const TDesC8& CISO2022JPConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
72 return KLit8Iso2022JpReplacementForUnconvertibleUnicodeCharacters;
75 LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
77 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
80 LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
82 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
85 LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
87 CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
90 TInt CISO2022JPConverterImpl::ConvertFromUnicode(
91 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
92 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
94 const TDesC16& aUnicode,
95 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
97 TFixedArray<CnvUtilities::SCharacterSet, 3> characterSets;
98 characterSets[0].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
99 characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
100 characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForAscii;
101 characterSets[1].iConversionData=&CnvJisRoman::ConversionData();
102 characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
103 characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
104 characterSets[2].iConversionData=&CnvJisX0208::ConversionData();
105 characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
106 characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
108 TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet |
109 CCnvCharacterSetConverter::EInputConversionFlagAssumeStartInDefaultCharacterSet;
110 return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array(),notUsed,inputConversionFlags);
113 TInt CISO2022JPConverterImpl::ConvertToUnicode(
114 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
116 const TDesC8& aForeign,
118 TInt& aNumberOfUnconvertibleCharacters,
119 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
121 return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
124 TBool CISO2022JPConverterImpl::IsInThisCharacterSetL(
126 TInt& aConfidenceLevel,
127 const TDesC8& aSample)
130 CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
134 CISO2022JPConverterImpl* CISO2022JPConverterImpl::NewL()
136 CISO2022JPConverterImpl* self = new(ELeave) CISO2022JPConverterImpl();
140 CISO2022JPConverterImpl::~CISO2022JPConverterImpl()
144 CISO2022JPConverterImpl::CISO2022JPConverterImpl()
148 const TImplementationProxy ImplementationTable[] =
150 IMPLEMENTATION_PROXY_ENTRY(0x100066A0, CISO2022JPConverterImpl::NewL)
153 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
155 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
157 return ImplementationTable;