os/textandloc/charconvfw/charconvplugins/src/plugins/EUCKR.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.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:    This file is a source code file for a charconv plug-in.
sl@0
    15
*                This plug-in supports EUC-KR.
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
sl@0
    21
// INCLUDES
sl@0
    22
#include <e32std.h>
sl@0
    23
#include <charconv.h>
sl@0
    24
#include <convgeneratedcpp.h>
sl@0
    25
#include <ecom/implementationproxy.h>
sl@0
    26
#include "cp949table.h"
sl@0
    27
#include "charactersetconverter.h"
sl@0
    28
// New Interface class
sl@0
    29
class CEUCKRImplementation : public CCharacterSetConverterPluginInterface
sl@0
    30
{
sl@0
    31
    public:
sl@0
    32
        virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
sl@0
    33
sl@0
    34
        virtual TInt ConvertFromUnicode(
sl@0
    35
            CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    36
            const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
sl@0
    37
            TDes8& aForeign, 
sl@0
    38
            const TDesC16& aUnicode, 
sl@0
    39
            CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters );
sl@0
    40
sl@0
    41
        virtual TInt ConvertToUnicode(
sl@0
    42
            CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    43
            TDes16& aUnicode, 
sl@0
    44
            const TDesC8& aForeign, 
sl@0
    45
            TInt&, 
sl@0
    46
            TInt& aNumberOfUnconvertibleCharacters, 
sl@0
    47
            TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter );
sl@0
    48
sl@0
    49
        virtual TBool IsInThisCharacterSetL(
sl@0
    50
            TBool& aSetToTrue, 
sl@0
    51
            TInt& aConfidenceLevel, 
sl@0
    52
            const TDesC8& );
sl@0
    53
sl@0
    54
        static CEUCKRImplementation* NewL();
sl@0
    55
sl@0
    56
        virtual ~CEUCKRImplementation();
sl@0
    57
sl@0
    58
    private:
sl@0
    59
        CEUCKRImplementation();
sl@0
    60
};
sl@0
    61
sl@0
    62
// FUNCTION DEFINITIONS
sl@0
    63
const TDesC8& CEUCKRImplementation::ReplacementForUnconvertibleUnicodeCharacters()
sl@0
    64
	{
sl@0
    65
	return CnvCp949Table::ReplacementForUnconvertibleUnicodeCharacters();
sl@0
    66
	}
sl@0
    67
sl@0
    68
TInt CEUCKRImplementation::ConvertFromUnicode(
sl@0
    69
    CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    70
    const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
sl@0
    71
    TDes8& aForeign, 
sl@0
    72
    const TDesC16& aUnicode, 
sl@0
    73
    CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
sl@0
    74
	{
sl@0
    75
	return CCnvCharacterSetConverter::DoConvertFromUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters);
sl@0
    76
	}
sl@0
    77
sl@0
    78
TInt CEUCKRImplementation::ConvertToUnicode(
sl@0
    79
    CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    80
    TDes16& aUnicode, 
sl@0
    81
    const TDesC8& aForeign, 
sl@0
    82
    TInt&, 
sl@0
    83
    TInt& aNumberOfUnconvertibleCharacters, 
sl@0
    84
    TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
sl@0
    85
	{
sl@0
    86
    return CCnvCharacterSetConverter::DoConvertToUnicode(CnvCp949Table::ConversionData(), aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
sl@0
    87
	}
sl@0
    88
sl@0
    89
sl@0
    90
TBool CEUCKRImplementation::IsInThisCharacterSetL(
sl@0
    91
    TBool& aSetToTrue, 
sl@0
    92
    TInt& aConfidenceLevel, 
sl@0
    93
    const TDesC8& /*aBuf*/)
sl@0
    94
	{
sl@0
    95
/*
sl@0
    96
	aSetToTrue=ETrue;
sl@0
    97
    aConfidenceLevel=50;
sl@0
    98
    
sl@0
    99
    TUint8 ch(0);
sl@0
   100
    for (TInt i=0;i<aBuf.Length();i++)
sl@0
   101
        {
sl@0
   102
        ch=aBuf[i];
sl@0
   103
        if (ch<0x7F)
sl@0
   104
            {
sl@0
   105
            continue;
sl@0
   106
            }
sl@0
   107
        else if (0xa1<=ch&&ch<=0xfe)
sl@0
   108
            {
sl@0
   109
            i++;
sl@0
   110
            __ASSERT_DEBUG(i<aBuf.Length(),User::Panic(_L("EUCKR"),__LINE__));
sl@0
   111
            }
sl@0
   112
        else
sl@0
   113
            {
sl@0
   114
            aConfidenceLevel=0;
sl@0
   115
            aSetToTrue=EFalse;
sl@0
   116
            break;
sl@0
   117
            }
sl@0
   118
        }    
sl@0
   119
	return aSetToTrue;
sl@0
   120
*/
sl@0
   121
	aSetToTrue=ETrue;
sl@0
   122
	aConfidenceLevel=0;
sl@0
   123
	return EFalse;
sl@0
   124
	}
sl@0
   125
sl@0
   126
CEUCKRImplementation* CEUCKRImplementation::NewL()
sl@0
   127
    {
sl@0
   128
    CEUCKRImplementation* self = new(ELeave) CEUCKRImplementation;
sl@0
   129
    return self;
sl@0
   130
    }
sl@0
   131
sl@0
   132
CEUCKRImplementation::CEUCKRImplementation()
sl@0
   133
    {
sl@0
   134
    //default constructor.. do nothing
sl@0
   135
    }
sl@0
   136
sl@0
   137
CEUCKRImplementation::~CEUCKRImplementation()
sl@0
   138
    {
sl@0
   139
    //default destructor .. do nothing
sl@0
   140
    }
sl@0
   141
sl@0
   142
// ECOM CREATION FUNCTION
sl@0
   143
const TImplementationProxy ImplementationTable[] = 
sl@0
   144
    {
sl@0
   145
    // Note: This is the same UID as defined in old mmp-file
sl@0
   146
    // Used also in 12221212.rss ( implementation_uid )
sl@0
   147
    IMPLEMENTATION_PROXY_ENTRY( 0x2000E526, CEUCKRImplementation::NewL )
sl@0
   148
    };
sl@0
   149
sl@0
   150
EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
sl@0
   151
    {
sl@0
   152
    aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy);
sl@0
   153
    return ImplementationTable;
sl@0
   154
    }
sl@0
   155