|
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 EUC-KR. |
|
17 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <charconv.h> |
|
25 #include <convgeneratedcpp.h> |
|
26 #include <ecom/implementationproxy.h> |
|
27 #include "cp949table.h" |
|
28 #include "charactersetconverter.h" |
|
29 // New Interface class |
|
30 class CEUCKRImplementation : public CCharacterSetConverterPluginInterface |
|
31 { |
|
32 public: |
|
33 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters(); |
|
34 |
|
35 virtual TInt ConvertFromUnicode( |
|
36 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
37 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
38 TDes8& aForeign, |
|
39 const TDesC16& aUnicode, |
|
40 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters ); |
|
41 |
|
42 virtual TInt ConvertToUnicode( |
|
43 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
44 TDes16& aUnicode, |
|
45 const TDesC8& aForeign, |
|
46 TInt&, |
|
47 TInt& aNumberOfUnconvertibleCharacters, |
|
48 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter ); |
|
49 |
|
50 virtual TBool IsInThisCharacterSetL( |
|
51 TBool& aSetToTrue, |
|
52 TInt& aConfidenceLevel, |
|
53 const TDesC8& ); |
|
54 |
|
55 static CEUCKRImplementation* NewL(); |
|
56 |
|
57 virtual ~CEUCKRImplementation(); |
|
58 |
|
59 private: |
|
60 CEUCKRImplementation(); |
|
61 }; |
|
62 |
|
63 // FUNCTION DEFINITIONS |
|
64 const TDesC8& CEUCKRImplementation::ReplacementForUnconvertibleUnicodeCharacters() |
|
65 { |
|
66 return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters(); |
|
67 } |
|
68 |
|
69 TInt CEUCKRImplementation::ConvertFromUnicode( |
|
70 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
71 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
72 TDes8& aForeign, |
|
73 const TDesC16& aUnicode, |
|
74 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters) |
|
75 { |
|
76 return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters); |
|
77 } |
|
78 |
|
79 TInt CEUCKRImplementation::ConvertToUnicode( |
|
80 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
81 TDes16& aUnicode, |
|
82 const TDesC8& aForeign, |
|
83 TInt&, |
|
84 TInt& aNumberOfUnconvertibleCharacters, |
|
85 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter) |
|
86 { |
|
87 return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter); |
|
88 } |
|
89 |
|
90 |
|
91 TBool CEUCKRImplementation::IsInThisCharacterSetL( |
|
92 TBool& aSetToTrue, |
|
93 TInt& aConfidenceLevel, |
|
94 const TDesC8& aBuf) |
|
95 { |
|
96 aSetToTrue=ETrue; |
|
97 aConfidenceLevel=200; |
|
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 |
|
122 CEUCKRImplementation* CEUCKRImplementation::NewL() |
|
123 { |
|
124 CEUCKRImplementation* self = new(ELeave) CEUCKRImplementation; |
|
125 return self; |
|
126 } |
|
127 |
|
128 CEUCKRImplementation::CEUCKRImplementation() |
|
129 { |
|
130 //default constructor.. do nothing |
|
131 } |
|
132 |
|
133 CEUCKRImplementation::~CEUCKRImplementation() |
|
134 { |
|
135 //default destructor .. do nothing |
|
136 } |
|
137 |
|
138 // ECOM CREATION FUNCTION |
|
139 const TImplementationProxy ImplementationTable[] = |
|
140 { |
|
141 // Note: This is the same UID as defined in old mmp-file |
|
142 // Used also in 12221212.rss ( implementation_uid ) |
|
143 IMPLEMENTATION_PROXY_ENTRY( 0x2000E526, CEUCKRImplementation::NewL ) |
|
144 }; |
|
145 |
|
146 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
147 { |
|
148 aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy); |
|
149 return ImplementationTable; |
|
150 } |
|
151 |