sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-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 |
#include "featmgr/featmgr.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
_LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
|
sl@0
|
31 |
_LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");
|
sl@0
|
32 |
_LIT8(KLit8EscapeSequenceForHalfWidthKatakana, "\x1b\x28\x49");
|
sl@0
|
33 |
_LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
|
sl@0
|
34 |
_LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44");
|
sl@0
|
35 |
_LIT8(KLit8JisReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
|
sl@0
|
36 |
|
sl@0
|
37 |
class CJISConverterImpl : public CCharacterSetConverterPluginInterface
|
sl@0
|
38 |
{
|
sl@0
|
39 |
|
sl@0
|
40 |
public:
|
sl@0
|
41 |
virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
|
sl@0
|
42 |
|
sl@0
|
43 |
virtual TInt ConvertFromUnicode(
|
sl@0
|
44 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
45 |
const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
|
sl@0
|
46 |
TDes8& aForeign,
|
sl@0
|
47 |
const TDesC16& aUnicode,
|
sl@0
|
48 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
|
sl@0
|
49 |
|
sl@0
|
50 |
virtual TInt ConvertToUnicode(
|
sl@0
|
51 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
52 |
TDes16& aUnicode,
|
sl@0
|
53 |
const TDesC8& aForeign,
|
sl@0
|
54 |
TInt& aState,
|
sl@0
|
55 |
TInt& aNumberOfUnconvertibleCharacters,
|
sl@0
|
56 |
TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
57 |
|
sl@0
|
58 |
virtual TBool IsInThisCharacterSetL(
|
sl@0
|
59 |
TBool& aSetToTrue,
|
sl@0
|
60 |
TInt& aConfidenceLevel,
|
sl@0
|
61 |
const TDesC8& aSample);
|
sl@0
|
62 |
|
sl@0
|
63 |
static CJISConverterImpl* NewL();
|
sl@0
|
64 |
virtual ~CJISConverterImpl();
|
sl@0
|
65 |
|
sl@0
|
66 |
private:
|
sl@0
|
67 |
CJISConverterImpl();
|
sl@0
|
68 |
void ConstructL();
|
sl@0
|
69 |
|
sl@0
|
70 |
};
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
const TDesC8& CJISConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
return KLit8JisReplacementForUnconvertibleUnicodeCharacters;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
LOCAL_C void ConvertFromHalfWidthKatakanaToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForHalfWidthKatakana, 1);
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
LOCAL_C void ConvertFromJisX0212ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0212_1990, 2);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
TInt CJISConverterImpl::ConvertFromUnicode(
|
sl@0
|
105 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
106 |
const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
|
sl@0
|
107 |
TDes8& aForeign,
|
sl@0
|
108 |
const TDesC16& aUnicode,
|
sl@0
|
109 |
CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TFixedArray<CnvUtilities::SCharacterSet, 5> characterSets;
|
sl@0
|
112 |
characterSets[0].iConversionData=&CnvJisRoman::ConversionData();
|
sl@0
|
113 |
characterSets[0].iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
|
sl@0
|
114 |
characterSets[0].iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
|
sl@0
|
115 |
characterSets[1].iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
|
sl@0
|
116 |
characterSets[1].iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
|
sl@0
|
117 |
characterSets[1].iEscapeSequence=&KLit8EscapeSequenceForAscii;
|
sl@0
|
118 |
characterSets[2].iConversionData=&CnvJisBase::HalfWidthKatakana7ConversionData();
|
sl@0
|
119 |
characterSets[2].iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakanaToJisInPlace;
|
sl@0
|
120 |
characterSets[2].iEscapeSequence=&KLit8EscapeSequenceForHalfWidthKatakana;
|
sl@0
|
121 |
characterSets[3].iConversionData=&CnvJisX0208::ConversionData();
|
sl@0
|
122 |
characterSets[3].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
|
sl@0
|
123 |
characterSets[3].iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
|
sl@0
|
124 |
characterSets[4].iConversionData=&CnvJisX0212::ConversionData();
|
sl@0
|
125 |
characterSets[4].iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToJisInPlace;
|
sl@0
|
126 |
characterSets[4].iEscapeSequence=&KLit8EscapeSequenceForJisX0212_1990;
|
sl@0
|
127 |
return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array());
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
TInt CJISConverterImpl::ConvertToUnicode(
|
sl@0
|
131 |
CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
|
sl@0
|
132 |
TDes16& aUnicode,
|
sl@0
|
133 |
const TDesC8& aForeign,
|
sl@0
|
134 |
TInt& aState,
|
sl@0
|
135 |
TInt& aNumberOfUnconvertibleCharacters,
|
sl@0
|
136 |
TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
TBool CJISConverterImpl::IsInThisCharacterSetL(
|
sl@0
|
142 |
TBool& aSetToTrue,
|
sl@0
|
143 |
TInt& aConfidenceLevel,
|
sl@0
|
144 |
const TDesC8& aSample)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
aSetToTrue=ETrue;
|
sl@0
|
147 |
CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
|
sl@0
|
148 |
return ETrue;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
CJISConverterImpl* CJISConverterImpl::NewL()
|
sl@0
|
152 |
{
|
sl@0
|
153 |
CJISConverterImpl* self = new(ELeave) CJISConverterImpl();
|
sl@0
|
154 |
CleanupStack::PushL(self);
|
sl@0
|
155 |
self->ConstructL();
|
sl@0
|
156 |
CleanupStack::Pop(self);
|
sl@0
|
157 |
return self;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
CJISConverterImpl::~CJISConverterImpl()
|
sl@0
|
161 |
{
|
sl@0
|
162 |
FeatureManager::UnInitializeLib();
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
CJISConverterImpl::CJISConverterImpl()
|
sl@0
|
166 |
{
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
void CJISConverterImpl::ConstructL()
|
sl@0
|
170 |
{
|
sl@0
|
171 |
FeatureManager::InitializeLibL();
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|
sl@0
|
174 |
const TImplementationProxy ImplementationTable[] =
|
sl@0
|
175 |
{
|
sl@0
|
176 |
IMPLEMENTATION_PROXY_ENTRY(0x10006066, CJISConverterImpl::NewL)
|
sl@0
|
177 |
};
|
sl@0
|
178 |
|
sl@0
|
179 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
sl@0
|
182 |
|
sl@0
|
183 |
return ImplementationTable;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|