|
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 |
|
16 * This plug-in supports CP949. |
|
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 CCP949Implementation : 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 CCP949Implementation* NewL(); |
|
55 |
|
56 virtual ~CCP949Implementation(); |
|
57 |
|
58 private: |
|
59 CCP949Implementation(); |
|
60 }; |
|
61 |
|
62 // FUNCTION DEFINITIONS |
|
63 const TDesC8& CCP949Implementation::ReplacementForUnconvertibleUnicodeCharacters() |
|
64 { |
|
65 return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters(); |
|
66 } |
|
67 |
|
68 TInt CCP949Implementation::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 CCP949Implementation::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 CCP949Implementation::IsInThisCharacterSetL( |
|
91 TBool& aSetToTrue, |
|
92 TInt& aConfidenceLevel, |
|
93 const TDesC8& aBuf) |
|
94 { |
|
95 aSetToTrue=ETrue; |
|
96 aConfidenceLevel=200; |
|
97 |
|
98 TUint8 ch(0); |
|
99 for (TInt i=0;i<aBuf.Length();i++) |
|
100 { |
|
101 ch=aBuf[i]; |
|
102 if (ch<0x7F) |
|
103 { |
|
104 continue; |
|
105 } |
|
106 else if (0xa1<=ch&&ch<=0xfe) |
|
107 { |
|
108 i++; |
|
109 __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("CP949"),__LINE__)); |
|
110 } |
|
111 else |
|
112 { |
|
113 aConfidenceLevel=0; |
|
114 aSetToTrue=EFalse; |
|
115 break; |
|
116 } |
|
117 } |
|
118 return aSetToTrue; |
|
119 } |
|
120 |
|
121 CCP949Implementation* CCP949Implementation::NewL() |
|
122 { |
|
123 CCP949Implementation* self = new(ELeave) CCP949Implementation; |
|
124 return self; |
|
125 } |
|
126 |
|
127 CCP949Implementation::CCP949Implementation() |
|
128 { |
|
129 //default constructor.. do nothing |
|
130 } |
|
131 |
|
132 CCP949Implementation::~CCP949Implementation() |
|
133 { |
|
134 //default destructor .. do nothing |
|
135 } |
|
136 |
|
137 // ECOM CREATION FUNCTION |
|
138 const TImplementationProxy ImplementationTable[] = |
|
139 { |
|
140 // Note: This is the same UID as defined in old mmp-file |
|
141 // Used also in 12221212.rss ( implementation_uid ) |
|
142 IMPLEMENTATION_PROXY_ENTRY( 0x200100FF, CCP949Implementation::NewL ) |
|
143 }; |
|
144 |
|
145 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
146 { |
|
147 aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy); |
|
148 return ImplementationTable; |
|
149 } |
|
150 |