1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconvplugins/src/plugins/ksc5601.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,154 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: ksc5601 conversion plugin
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +// INCLUDES
1.23 +#include <e32std.h>
1.24 +#include <charconv.h>
1.25 +#include <convgeneratedcpp.h>
1.26 +#include <ecom/implementationproxy.h>
1.27 +#include "cp949table.h"
1.28 +#include "charactersetconverter.h"
1.29 +
1.30 +// New Interface class
1.31 +class CKSC5601Implementation : public CCharacterSetConverterPluginInterface
1.32 +{
1.33 + public:
1.34 + virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
1.35 +
1.36 + virtual TInt ConvertFromUnicode(
1.37 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.38 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.39 + TDes8& aForeign,
1.40 + const TDesC16& aUnicode,
1.41 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters );
1.42 +
1.43 + virtual TInt ConvertToUnicode(
1.44 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.45 + TDes16& aUnicode,
1.46 + const TDesC8& aForeign,
1.47 + TInt&,
1.48 + TInt& aNumberOfUnconvertibleCharacters,
1.49 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter );
1.50 +
1.51 + virtual TBool IsInThisCharacterSetL(
1.52 + TBool& aSetToTrue,
1.53 + TInt& aConfidenceLevel,
1.54 + const TDesC8& );
1.55 +
1.56 + static CKSC5601Implementation* NewL();
1.57 +
1.58 + virtual ~CKSC5601Implementation();
1.59 +
1.60 + private:
1.61 + CKSC5601Implementation();
1.62 +};
1.63 +
1.64 +// FUNCTION DEFINITIONS
1.65 +const TDesC8& CKSC5601Implementation::ReplacementForUnconvertibleUnicodeCharacters()
1.66 + {
1.67 + return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters();
1.68 + }
1.69 +
1.70 +TInt CKSC5601Implementation::ConvertFromUnicode(
1.71 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.72 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.73 + TDes8& aForeign,
1.74 + const TDesC16& aUnicode,
1.75 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
1.76 + {
1.77 + return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
1.78 + }
1.79 +
1.80 +TInt CKSC5601Implementation::ConvertToUnicode(
1.81 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.82 + TDes16& aUnicode,
1.83 + const TDesC8& aForeign,
1.84 + TInt&,
1.85 + TInt& aNumberOfUnconvertibleCharacters,
1.86 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
1.87 + {
1.88 + return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.89 + }
1.90 +
1.91 +
1.92 +TBool CKSC5601Implementation::IsInThisCharacterSetL(
1.93 + TBool& aSetToTrue,
1.94 + TInt& aConfidenceLevel,
1.95 + const TDesC8& /*aBuf*/)
1.96 + {
1.97 +/*
1.98 + aSetToTrue=ETrue;
1.99 + aConfidenceLevel=50;
1.100 +
1.101 + TUint8 ch(0);
1.102 + for (TInt i=0;i<aBuf.Length();i++)
1.103 + {
1.104 + ch=aBuf[i];
1.105 + if (ch<0x7F)
1.106 + {
1.107 + continue;
1.108 + }
1.109 + else if (0xa1<=ch&&ch<=0xfe)
1.110 + {
1.111 + i++;
1.112 + __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("KSC5601"),__LINE__));
1.113 + }
1.114 + else
1.115 + {
1.116 + aConfidenceLevel=0;
1.117 + aSetToTrue=EFalse;
1.118 + break;
1.119 + }
1.120 + }
1.121 + return aSetToTrue;
1.122 +*/
1.123 + aSetToTrue=ETrue;
1.124 + aConfidenceLevel=0;
1.125 + return EFalse;
1.126 + }
1.127 +
1.128 +CKSC5601Implementation* CKSC5601Implementation::NewL()
1.129 + {
1.130 + CKSC5601Implementation* self = new(ELeave) CKSC5601Implementation;
1.131 + return self;
1.132 + }
1.133 +
1.134 +CKSC5601Implementation::CKSC5601Implementation()
1.135 + {
1.136 + //default constructor.. do nothing
1.137 + }
1.138 +
1.139 +CKSC5601Implementation::~CKSC5601Implementation()
1.140 + {
1.141 + //default destructor .. do nothing
1.142 + }
1.143 +
1.144 +// ECOM CREATION FUNCTION
1.145 +const TImplementationProxy ImplementationTable[] =
1.146 + {
1.147 + // Note: This is the same UID as defined in old mmp-file
1.148 + // Used also in 12221212.rss ( implementation_uid )
1.149 + IMPLEMENTATION_PROXY_ENTRY( 0x200113CD, CKSC5601Implementation::NewL )
1.150 + };
1.151 +
1.152 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
1.153 + {
1.154 + aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy);
1.155 + return ImplementationTable;
1.156 + }
1.157 +