os/textandloc/charconvfw/charconvplugins/src/plugins/ksc5601.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) 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:   ksc5601 conversion plugin
    15 *
    16 */
    17 
    18 
    19 // INCLUDES
    20 #include <e32std.h>
    21 #include <charconv.h>
    22 #include <convgeneratedcpp.h>
    23 #include <ecom/implementationproxy.h>
    24 #include "cp949table.h"
    25 #include "charactersetconverter.h"
    26 
    27 // New Interface class
    28 class CKSC5601Implementation : public CCharacterSetConverterPluginInterface
    29 {
    30     public:
    31         virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
    32 
    33         virtual TInt ConvertFromUnicode(
    34             CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    35             const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    36             TDes8& aForeign, 
    37             const TDesC16& aUnicode, 
    38             CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters );
    39 
    40         virtual TInt ConvertToUnicode(
    41             CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    42             TDes16& aUnicode, 
    43             const TDesC8& aForeign, 
    44             TInt&, 
    45             TInt& aNumberOfUnconvertibleCharacters, 
    46             TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter );
    47 
    48         virtual TBool IsInThisCharacterSetL(
    49             TBool& aSetToTrue, 
    50             TInt& aConfidenceLevel, 
    51             const TDesC8& );
    52 
    53         static CKSC5601Implementation* NewL();
    54 
    55         virtual ~CKSC5601Implementation();
    56 
    57     private:
    58         CKSC5601Implementation();
    59 };
    60 
    61 // FUNCTION DEFINITIONS
    62 const TDesC8& CKSC5601Implementation::ReplacementForUnconvertibleUnicodeCharacters()
    63 	{
    64 	return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters();
    65 	}
    66 
    67 TInt CKSC5601Implementation::ConvertFromUnicode(
    68     CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    69     const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    70     TDes8& aForeign, 
    71     const TDesC16& aUnicode, 
    72     CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
    73 	{
    74 	return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
    75 	}
    76 
    77 TInt CKSC5601Implementation::ConvertToUnicode(
    78     CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    79     TDes16& aUnicode, 
    80     const TDesC8& aForeign, 
    81     TInt&, 
    82     TInt& aNumberOfUnconvertibleCharacters, 
    83     TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
    84 	{
    85     return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    86 	}
    87 
    88 
    89 TBool CKSC5601Implementation::IsInThisCharacterSetL(
    90     TBool& aSetToTrue, 
    91     TInt& aConfidenceLevel, 
    92     const TDesC8& /*aBuf*/)
    93 	{
    94 /*	
    95     aSetToTrue=ETrue;
    96     aConfidenceLevel=50;
    97     
    98     TUint8 ch(0);
    99     for (TInt i=0;i<aBuf.Length();i++)
   100         {
   101         ch=aBuf[i];
   102         if (ch<0x7F)
   103             {
   104             continue;
   105             }
   106         else if (0xa1<=ch&&ch<=0xfe)
   107             {
   108             i++;
   109             __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("KSC5601"),__LINE__));
   110             }
   111         else
   112             {
   113             aConfidenceLevel=0;
   114             aSetToTrue=EFalse;
   115             break;
   116             }
   117         }    
   118 	return aSetToTrue;
   119 */
   120 	aSetToTrue=ETrue;
   121 	aConfidenceLevel=0;
   122 	return EFalse;
   123 	}
   124 
   125 CKSC5601Implementation* CKSC5601Implementation::NewL()
   126     {
   127     CKSC5601Implementation* self = new(ELeave) CKSC5601Implementation;
   128     return self;
   129     }
   130 
   131 CKSC5601Implementation::CKSC5601Implementation()
   132     {
   133     //default constructor.. do nothing
   134     }
   135 
   136 CKSC5601Implementation::~CKSC5601Implementation()
   137     {
   138     //default destructor .. do nothing
   139     }
   140 
   141 // ECOM CREATION FUNCTION
   142 const TImplementationProxy ImplementationTable[] = 
   143     {
   144     // Note: This is the same UID as defined in old mmp-file
   145     // Used also in 12221212.rss ( implementation_uid )
   146     IMPLEMENTATION_PROXY_ENTRY( 0x200113CD, CKSC5601Implementation::NewL )
   147     };
   148 
   149 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
   150     {
   151     aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy);
   152     return ImplementationTable;
   153     }
   154