1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconvplugins/src/plugins/EUCKR.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,155 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2004 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: This file is a source code file for a charconv plug-in.
1.18 +* This plug-in supports EUC-KR.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +// INCLUDES
1.25 +#include <e32std.h>
1.26 +#include <charconv.h>
1.27 +#include <convgeneratedcpp.h>
1.28 +#include <ecom/implementationproxy.h>
1.29 +#include "cp949table.h"
1.30 +#include "charactersetconverter.h"
1.31 +// New Interface class
1.32 +class CEUCKRImplementation : public CCharacterSetConverterPluginInterface
1.33 +{
1.34 + public:
1.35 + virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
1.36 +
1.37 + virtual TInt ConvertFromUnicode(
1.38 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.39 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.40 + TDes8& aForeign,
1.41 + const TDesC16& aUnicode,
1.42 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters );
1.43 +
1.44 + virtual TInt ConvertToUnicode(
1.45 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.46 + TDes16& aUnicode,
1.47 + const TDesC8& aForeign,
1.48 + TInt&,
1.49 + TInt& aNumberOfUnconvertibleCharacters,
1.50 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter );
1.51 +
1.52 + virtual TBool IsInThisCharacterSetL(
1.53 + TBool& aSetToTrue,
1.54 + TInt& aConfidenceLevel,
1.55 + const TDesC8& );
1.56 +
1.57 + static CEUCKRImplementation* NewL();
1.58 +
1.59 + virtual ~CEUCKRImplementation();
1.60 +
1.61 + private:
1.62 + CEUCKRImplementation();
1.63 +};
1.64 +
1.65 +// FUNCTION DEFINITIONS
1.66 +const TDesC8& CEUCKRImplementation::ReplacementForUnconvertibleUnicodeCharacters()
1.67 + {
1.68 + return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters();
1.69 + }
1.70 +
1.71 +TInt CEUCKRImplementation::ConvertFromUnicode(
1.72 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.73 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.74 + TDes8& aForeign,
1.75 + const TDesC16& aUnicode,
1.76 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
1.77 + {
1.78 + return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
1.79 + }
1.80 +
1.81 +TInt CEUCKRImplementation::ConvertToUnicode(
1.82 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.83 + TDes16& aUnicode,
1.84 + const TDesC8& aForeign,
1.85 + TInt&,
1.86 + TInt& aNumberOfUnconvertibleCharacters,
1.87 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
1.88 + {
1.89 + return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.90 + }
1.91 +
1.92 +
1.93 +TBool CEUCKRImplementation::IsInThisCharacterSetL(
1.94 + TBool& aSetToTrue,
1.95 + TInt& aConfidenceLevel,
1.96 + const TDesC8& /*aBuf*/)
1.97 + {
1.98 +/*
1.99 + aSetToTrue=ETrue;
1.100 + aConfidenceLevel=50;
1.101 +
1.102 + TUint8 ch(0);
1.103 + for (TInt i=0;i<aBuf.Length();i++)
1.104 + {
1.105 + ch=aBuf[i];
1.106 + if (ch<0x7F)
1.107 + {
1.108 + continue;
1.109 + }
1.110 + else if (0xa1<=ch&&ch<=0xfe)
1.111 + {
1.112 + i++;
1.113 + __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("EUCKR"),__LINE__));
1.114 + }
1.115 + else
1.116 + {
1.117 + aConfidenceLevel=0;
1.118 + aSetToTrue=EFalse;
1.119 + break;
1.120 + }
1.121 + }
1.122 + return aSetToTrue;
1.123 +*/
1.124 + aSetToTrue=ETrue;
1.125 + aConfidenceLevel=0;
1.126 + return EFalse;
1.127 + }
1.128 +
1.129 +CEUCKRImplementation* CEUCKRImplementation::NewL()
1.130 + {
1.131 + CEUCKRImplementation* self = new(ELeave) CEUCKRImplementation;
1.132 + return self;
1.133 + }
1.134 +
1.135 +CEUCKRImplementation::CEUCKRImplementation()
1.136 + {
1.137 + //default constructor.. do nothing
1.138 + }
1.139 +
1.140 +CEUCKRImplementation::~CEUCKRImplementation()
1.141 + {
1.142 + //default destructor .. do nothing
1.143 + }
1.144 +
1.145 +// ECOM CREATION FUNCTION
1.146 +const TImplementationProxy ImplementationTable[] =
1.147 + {
1.148 + // Note: This is the same UID as defined in old mmp-file
1.149 + // Used also in 12221212.rss ( implementation_uid )
1.150 + IMPLEMENTATION_PROXY_ENTRY( 0x2000E526, CEUCKRImplementation::NewL )
1.151 + };
1.152 +
1.153 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
1.154 + {
1.155 + aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy);
1.156 + return ImplementationTable;
1.157 + }
1.158 +