1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconvplugins/src/plugins/gb2312.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,121 @@
1.4 +/*
1.5 +* Copyright (c) 1997-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:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <charconv.h>
1.24 +#include "gb2312.h"
1.25 +#include <ecom/implementationproxy.h>
1.26 +#include <charactersetconverter.h>
1.27 +
1.28 +class CGB2312ConverterImpl : public CCharacterSetConverterPluginInterface
1.29 + {
1.30 +
1.31 +public:
1.32 + virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
1.33 +
1.34 + virtual TInt ConvertFromUnicode(
1.35 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.36 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.37 + TDes8& aForeign,
1.38 + const TDesC16& aUnicode,
1.39 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
1.40 +
1.41 + virtual TInt ConvertToUnicode(
1.42 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.43 + TDes16& aUnicode,
1.44 + const TDesC8& aForeign,
1.45 + TInt& aState,
1.46 + TInt& aNumberOfUnconvertibleCharacters,
1.47 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.48 +
1.49 + virtual TBool IsInThisCharacterSetL(
1.50 + TBool& aSetToTrue,
1.51 + TInt& aConfidenceLevel,
1.52 + const TDesC8& aSample);
1.53 +
1.54 + static CGB2312ConverterImpl* NewL();
1.55 + virtual ~CGB2312ConverterImpl();
1.56 +
1.57 +private:
1.58 + CGB2312ConverterImpl();
1.59 +
1.60 + };
1.61 +
1.62 +
1.63 +
1.64 +const TDesC8& CGB2312ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
1.65 + {
1.66 + return CnvGb2312::ReplacementForUnconvertibleUnicodeCharacters();
1.67 + }
1.68 +
1.69 +TInt CGB2312ConverterImpl::ConvertFromUnicode(
1.70 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.71 + const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
1.72 + TDes8& aForeign,
1.73 + const TDesC16& aUnicode,
1.74 + CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
1.75 + {
1.76 + return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvGb2312::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
1.77 + }
1.78 +
1.79 +TInt CGB2312ConverterImpl::ConvertToUnicode(
1.80 + CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
1.81 + TDes16& aUnicode,
1.82 + const TDesC8& aForeign,
1.83 + TInt& /*aState*/,
1.84 + TInt& aNumberOfUnconvertibleCharacters,
1.85 + TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
1.86 + {
1.87 + return CCnvCharacterSetConverter::DoConvertToUnicode(CnvGb2312::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
1.88 + }
1.89 +
1.90 +TBool CGB2312ConverterImpl::IsInThisCharacterSetL(
1.91 + TBool& aSetToTrue,
1.92 + TInt& aConfidenceLevel,
1.93 + const TDesC8& aSample)
1.94 + {
1.95 + aSetToTrue=ETrue;
1.96 + return CnvGb2312::IsCharGBBased(aConfidenceLevel, aSample);
1.97 + }
1.98 +
1.99 +CGB2312ConverterImpl* CGB2312ConverterImpl::NewL()
1.100 + {
1.101 + CGB2312ConverterImpl* self = new(ELeave) CGB2312ConverterImpl();
1.102 + return self;
1.103 + }
1.104 +
1.105 +CGB2312ConverterImpl::~CGB2312ConverterImpl()
1.106 + {
1.107 + }
1.108 +
1.109 +CGB2312ConverterImpl::CGB2312ConverterImpl()
1.110 + {
1.111 + }
1.112 +
1.113 +const TImplementationProxy ImplementationTable[] =
1.114 + {
1.115 + IMPLEMENTATION_PROXY_ENTRY(0x10000FBE,CGB2312ConverterImpl::NewL)
1.116 + };
1.117 +
1.118 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.119 + {
1.120 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.121 +
1.122 + return ImplementationTable;
1.123 + }
1.124 +