sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <charconv.h>
|
sl@0
|
21 |
#include <convutils.h>
|
sl@0
|
22 |
#include "jisbase.h"
|
sl@0
|
23 |
#include "jisx0201.h"
|
sl@0
|
24 |
#include "jisx0208.h"
|
sl@0
|
25 |
#include "jisx0212.h"
|
sl@0
|
26 |
#include <ecom/implementationproxy.h>
|
sl@0
|
27 |
#include <charactersetconverter.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
_LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
|
sl@0
|
30 |
_LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
|
sl@0
|
31 |
_LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
|
sl@0
|
32 |
_LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44");
|
sl@0
|
33 |
_LIT8(KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
class CISO2022JP1ConverterImpl : public CCharacterSetConverterPluginInterface
|
sl@0
|
37 |
{
|
sl@0
|
38 |
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
|
sl@0
|
41 |
|
sl@0
|
42 |
virtual TInt ConvertFromUnicode(
|
sl@0
|
43 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
44 |
const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
|
sl@0
|
45 |
TDes8& aForeign,
|
sl@0
|
46 |
const TDesC16& aUnicode,
|
sl@0
|
47 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
|
sl@0
|
48 |
|
sl@0
|
49 |
virtual TInt ConvertToUnicode(
|
sl@0
|
50 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
51 |
TDes16& aUnicode,
|
sl@0
|
52 |
const TDesC8& aForeign,
|
sl@0
|
53 |
TInt& aState,
|
sl@0
|
54 |
TInt& aNumberOfUnconvertibleCharacters,
|
sl@0
|
55 |
TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
56 |
|
sl@0
|
57 |
virtual TBool IsInThisCharacterSetL(
|
sl@0
|
58 |
TBool& aSetToTrue,
|
sl@0
|
59 |
TInt& aConfidenceLevel,
|
sl@0
|
60 |
const TDesC8& aSample);
|
sl@0
|
61 |
|
sl@0
|
62 |
static CISO2022JP1ConverterImpl* NewL();
|
sl@0
|
63 |
virtual ~CISO2022JP1ConverterImpl();
|
sl@0
|
64 |
|
sl@0
|
65 |
private:
|
sl@0
|
66 |
CISO2022JP1ConverterImpl();
|
sl@0
|
67 |
|
sl@0
|
68 |
};
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
const TDesC8& CISO2022JP1ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
|
sl@0
|
72 |
{
|
sl@0
|
73 |
return KLit8Iso2022Jp1ReplacementForUnconvertibleUnicodeCharacters;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
TInt CISO2022JP1ConverterImpl::ConvertFromUnicode(
|
sl@0
|
97 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
98 |
const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
|
sl@0
|
99 |
TDes8& aForeign,
|
sl@0
|
100 |
const TDesC16& aUnicode,
|
sl@0
|
101 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
TFixedArray<CnvUtilities::SCharacterSet, 4> characterSets;
|
sl@0
|
104 |
characterSets[0].iConversionData=&CnvJisRoman::ConversionData();
|
sl@0
|
105 |
characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
|
sl@0
|
106 |
characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
|
sl@0
|
107 |
characterSets[1].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
|
sl@0
|
108 |
characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
|
sl@0
|
109 |
characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForAscii;
|
sl@0
|
110 |
characterSets[2].iConversionData=&CnvJisX0208::ConversionData();
|
sl@0
|
111 |
characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
|
sl@0
|
112 |
characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
|
sl@0
|
113 |
characterSets[3].iConversionData=&CnvJisX0212::ConversionData();
|
sl@0
|
114 |
characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
|
sl@0
|
115 |
characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
|
sl@0
|
116 |
TUint notUsed;
|
sl@0
|
117 |
TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet;
|
sl@0
|
118 |
return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array(),notUsed,inputConversionFlags);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
TInt CISO2022JP1ConverterImpl::ConvertToUnicode(
|
sl@0
|
122 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
123 |
TDes16& aUnicode,
|
sl@0
|
124 |
const TDesC8& aForeign,
|
sl@0
|
125 |
TInt& aState,
|
sl@0
|
126 |
TInt& aNumberOfUnconvertibleCharacters,
|
sl@0
|
127 |
TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
TBool CISO2022JP1ConverterImpl::IsInThisCharacterSetL(
|
sl@0
|
133 |
TBool& aSetToTrue,
|
sl@0
|
134 |
TInt& aConfidenceLevel,
|
sl@0
|
135 |
const TDesC8& aSample)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
aSetToTrue=ETrue;
|
sl@0
|
138 |
CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
|
sl@0
|
139 |
return ETrue;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
CISO2022JP1ConverterImpl* CISO2022JP1ConverterImpl::NewL()
|
sl@0
|
143 |
{
|
sl@0
|
144 |
CISO2022JP1ConverterImpl* self = new(ELeave) CISO2022JP1ConverterImpl();
|
sl@0
|
145 |
return self;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
CISO2022JP1ConverterImpl::~CISO2022JP1ConverterImpl()
|
sl@0
|
149 |
{
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
CISO2022JP1ConverterImpl::CISO2022JP1ConverterImpl()
|
sl@0
|
153 |
{
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
|
sl@0
|
157 |
const TImplementationProxy ImplementationTable[] =
|
sl@0
|
158 |
{
|
sl@0
|
159 |
IMPLEMENTATION_PROXY_ENTRY(0x100066A3, CISO2022JP1ConverterImpl::NewL)
|
sl@0
|
160 |
};
|
sl@0
|
161 |
|
sl@0
|
162 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
sl@0
|
165 |
|
sl@0
|
166 |
return ImplementationTable;
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|