|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ksc5601 conversion plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDES |
|
19 #include <e32std.h> |
|
20 #include <charconv.h> |
|
21 #include <convgeneratedcpp.h> |
|
22 #include <ecom/implementationproxy.h> |
|
23 #include "cp949table.h" |
|
24 #include "charactersetconverter.h" |
|
25 |
|
26 // New Interface class |
|
27 class CKSC5601Implementation : public CCharacterSetConverterPluginInterface |
|
28 { |
|
29 public: |
|
30 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters(); |
|
31 |
|
32 virtual TInt ConvertFromUnicode( |
|
33 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
34 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
35 TDes8& aForeign, |
|
36 const TDesC16& aUnicode, |
|
37 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters ); |
|
38 |
|
39 virtual TInt ConvertToUnicode( |
|
40 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
41 TDes16& aUnicode, |
|
42 const TDesC8& aForeign, |
|
43 TInt&, |
|
44 TInt& aNumberOfUnconvertibleCharacters, |
|
45 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter ); |
|
46 |
|
47 virtual TBool IsInThisCharacterSetL( |
|
48 TBool& aSetToTrue, |
|
49 TInt& aConfidenceLevel, |
|
50 const TDesC8& ); |
|
51 |
|
52 static CKSC5601Implementation* NewL(); |
|
53 |
|
54 virtual ~CKSC5601Implementation(); |
|
55 |
|
56 private: |
|
57 CKSC5601Implementation(); |
|
58 }; |
|
59 |
|
60 // FUNCTION DEFINITIONS |
|
61 const TDesC8& CKSC5601Implementation::ReplacementForUnconvertibleUnicodeCharacters() |
|
62 { |
|
63 return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters(); |
|
64 } |
|
65 |
|
66 TInt CKSC5601Implementation::ConvertFromUnicode( |
|
67 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
68 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
69 TDes8& aForeign, |
|
70 const TDesC16& aUnicode, |
|
71 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters) |
|
72 { |
|
73 return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters); |
|
74 } |
|
75 |
|
76 TInt CKSC5601Implementation::ConvertToUnicode( |
|
77 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
78 TDes16& aUnicode, |
|
79 const TDesC8& aForeign, |
|
80 TInt&, |
|
81 TInt& aNumberOfUnconvertibleCharacters, |
|
82 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter) |
|
83 { |
|
84 return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter); |
|
85 } |
|
86 |
|
87 |
|
88 TBool CKSC5601Implementation::IsInThisCharacterSetL( |
|
89 TBool& aSetToTrue, |
|
90 TInt& aConfidenceLevel, |
|
91 const TDesC8& aBuf) |
|
92 { |
|
93 aSetToTrue=ETrue; |
|
94 aConfidenceLevel=200; |
|
95 |
|
96 TUint8 ch(0); |
|
97 for (TInt i=0;i<aBuf.Length();i++) |
|
98 { |
|
99 ch=aBuf[i]; |
|
100 if (ch<0x7F) |
|
101 { |
|
102 continue; |
|
103 } |
|
104 else if (0xa1<=ch&&ch<=0xfe) |
|
105 { |
|
106 i++; |
|
107 __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("KSC5601"),__LINE__)); |
|
108 } |
|
109 else |
|
110 { |
|
111 aConfidenceLevel=0; |
|
112 aSetToTrue=EFalse; |
|
113 break; |
|
114 } |
|
115 } |
|
116 return aSetToTrue; |
|
117 } |
|
118 |
|
119 CKSC5601Implementation* CKSC5601Implementation::NewL() |
|
120 { |
|
121 CKSC5601Implementation* self = new(ELeave) CKSC5601Implementation; |
|
122 return self; |
|
123 } |
|
124 |
|
125 CKSC5601Implementation::CKSC5601Implementation() |
|
126 { |
|
127 //default constructor.. do nothing |
|
128 } |
|
129 |
|
130 CKSC5601Implementation::~CKSC5601Implementation() |
|
131 { |
|
132 //default destructor .. do nothing |
|
133 } |
|
134 |
|
135 // ECOM CREATION FUNCTION |
|
136 const TImplementationProxy ImplementationTable[] = |
|
137 { |
|
138 // Note: This is the same UID as defined in old mmp-file |
|
139 // Used also in 12221212.rss ( implementation_uid ) |
|
140 IMPLEMENTATION_PROXY_ENTRY( 0x200113CD, CKSC5601Implementation::NewL ) |
|
141 }; |
|
142 |
|
143 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
144 { |
|
145 aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy); |
|
146 return ImplementationTable; |
|
147 } |
|
148 |