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