os/textandloc/charconvfw/charconvplugins/src/plugins/gb2312.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1997-2009 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: 
    15 *
    16 */
    17 
    18 
    19 #include <e32std.h>
    20 #include <charconv.h>
    21 #include "gb2312.h"
    22 #include <ecom/implementationproxy.h>
    23 #include <charactersetconverter.h>
    24 
    25 class CGB2312ConverterImpl : public CCharacterSetConverterPluginInterface
    26 	{
    27 
    28 public:
    29 	virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
    30 
    31 	virtual TInt ConvertFromUnicode(
    32 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    33 		const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    34 		TDes8& aForeign, 
    35 		const TDesC16& aUnicode, 
    36 		CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
    37 
    38 	virtual TInt ConvertToUnicode(
    39 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    40 		TDes16& aUnicode, 
    41 		const TDesC8& aForeign, 
    42 		TInt& aState, 
    43 		TInt& aNumberOfUnconvertibleCharacters, 
    44 		TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    45 
    46 	virtual TBool IsInThisCharacterSetL(
    47 		TBool& aSetToTrue, 
    48 		TInt& aConfidenceLevel, 
    49 		const TDesC8& aSample);
    50 
    51 	static CGB2312ConverterImpl* NewL();
    52 	virtual ~CGB2312ConverterImpl();
    53 
    54 private:
    55 	CGB2312ConverterImpl();
    56 
    57 	};
    58 
    59 
    60 
    61 const TDesC8& CGB2312ConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
    62 	{
    63 	return CnvGb2312::ReplacementForUnconvertibleUnicodeCharacters();
    64 	}
    65 
    66 TInt CGB2312ConverterImpl::ConvertFromUnicode(
    67 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    68 		const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    69 		TDes8& aForeign, 
    70 		const TDesC16& aUnicode, 
    71 		CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
    72 	{
    73 	return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvGb2312::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
    74 	}
    75 
    76 TInt CGB2312ConverterImpl::ConvertToUnicode(
    77 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    78 		TDes16& aUnicode, 
    79 		const TDesC8& aForeign, 
    80 		TInt& /*aState*/, 
    81 		TInt& aNumberOfUnconvertibleCharacters, 
    82 		TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
    83 	{
    84 	return CCnvCharacterSetConverter::DoConvertToUnicode(CnvGb2312::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    85 	}
    86 
    87 TBool CGB2312ConverterImpl::IsInThisCharacterSetL(
    88 		TBool& aSetToTrue, 
    89 		TInt& aConfidenceLevel, 
    90 		const TDesC8& aSample)
    91 	{
    92 	aSetToTrue=ETrue;
    93 	return CnvGb2312::IsCharGBBased(aConfidenceLevel, aSample);
    94 	}
    95 
    96 CGB2312ConverterImpl* CGB2312ConverterImpl::NewL()
    97 	{
    98 	CGB2312ConverterImpl* self = new(ELeave) CGB2312ConverterImpl();
    99 	return self;
   100 	}
   101 
   102 CGB2312ConverterImpl::~CGB2312ConverterImpl()
   103 	{
   104 	}
   105 
   106 CGB2312ConverterImpl::CGB2312ConverterImpl()
   107 	{
   108 	}
   109 
   110 const TImplementationProxy ImplementationTable[] = 
   111 	{
   112 		IMPLEMENTATION_PROXY_ENTRY(0x10000FBE,CGB2312ConverterImpl::NewL)
   113 	};
   114 
   115 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   116 	{
   117 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   118 
   119 	return ImplementationTable;
   120 	}
   121