os/textandloc/charconvfw/charconvplugins/src/plugins/EUCJP_PACKED_2.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) 1997-2009 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:       
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#include "PictographObserver.h"
sl@0
    19
sl@0
    20
#include <e32std.h>
sl@0
    21
#include <charconv.h>
sl@0
    22
#include <convutils.h>
sl@0
    23
#include "jisx0201.h"
sl@0
    24
#include "jisx0208.h"
sl@0
    25
#include "jisx0212.h"
sl@0
    26
#include <ecom/implementationproxy.h>
sl@0
    27
#include "charactersetconverter.h"
sl@0
    28
#include "featmgr/featmgr.h" 
sl@0
    29
sl@0
    30
const TUint KSingleShift2=0x8e;
sl@0
    31
const TUint KSingleShift3=0x8f;
sl@0
    32
sl@0
    33
// SecureID for Brower app
sl@0
    34
const TUint32 KBrowserSecureId = 0x10008D39;
sl@0
    35
// Define for converting from YenSign to BackSlash
sl@0
    36
const TUint KCharacterCodeForYenSign = 0x00A5;
sl@0
    37
const TUint KCharacterCodeForBackSlash = 0x005C;
sl@0
    38
sl@0
    39
_LIT8(KLit8EucJpPackedReplacementForUnconvertibleUnicodeCharacters, "\xa1\xa9"); // fullwidth question mark
sl@0
    40
sl@0
    41
#if defined(_DEBUG)
sl@0
    42
sl@0
    43
_LIT(KLitPanicText, "EUCJP_PACKED");
sl@0
    44
sl@0
    45
enum TPanic
sl@0
    46
    {
sl@0
    47
    EPanicNothingToConvert1=1,
sl@0
    48
    EPanicNothingToConvert2,
sl@0
    49
    EPanicNothingToConvert3,
sl@0
    50
    EPanicNothingToConvert4,
sl@0
    51
    EPanicNothingToConvert5,
sl@0
    52
    EPanicNothingToConvert6,
sl@0
    53
    EPanicOddNumberOfBytes1,
sl@0
    54
    EPanicOddNumberOfBytes2,
sl@0
    55
    EPanicOddNumberOfBytes3,
sl@0
    56
    EPanicOddNumberOfBytes4,
sl@0
    57
    EPanicOddNumberOfBytes5,
sl@0
    58
    EPanicOddNumberOfBytes6,
sl@0
    59
    EPanicBadHighBit1,
sl@0
    60
    EPanicBadHighBit2,
sl@0
    61
    EPanicBadHighBit3,
sl@0
    62
    EPanicBadHighBit4,
sl@0
    63
    EPanicBadHighBit5,
sl@0
    64
    EPanicBadHighBit6,
sl@0
    65
    EPanicBadHighBit7,
sl@0
    66
    EPanicBadPointers1,
sl@0
    67
    EPanicBadPointers2,
sl@0
    68
    EPanicBadPointers3,
sl@0
    69
    EPanicBadPointers4,
sl@0
    70
    EPanicBadPointers5,
sl@0
    71
    EPanicBadPointers6,
sl@0
    72
    EPanicBadPointers7,
sl@0
    73
    EPanicBadPointers8,
sl@0
    74
    EPanicBadPointers9,
sl@0
    75
    EPanicBadPointers10,
sl@0
    76
    EPanicBadPointers11,
sl@0
    77
    EPanicBadPointers12,
sl@0
    78
    EPanicBadPointers13,
sl@0
    79
    EPanicBadPointers14,
sl@0
    80
    EPanicBadPointers15,
sl@0
    81
    EPanicBadPointers16,
sl@0
    82
    EPanicBadPointers17,
sl@0
    83
    EPanicBadPointers18,
sl@0
    84
    EPanicBadPointers19,
sl@0
    85
    EPanicBadPointers20,
sl@0
    86
    EPanicBadPointers21,
sl@0
    87
    EPanicBadPointers22,
sl@0
    88
    EPanicBadPointers23,
sl@0
    89
    EPanicBadPointers24,
sl@0
    90
    EPanicBadPointers25,
sl@0
    91
    EPanicBadPointers26,
sl@0
    92
    EPanicBadPointers27,
sl@0
    93
    EPanicBadPointers28,
sl@0
    94
    EPanicBadPointers29,
sl@0
    95
    EPanicBadPointers30,
sl@0
    96
    EPanicBadPointers31,
sl@0
    97
    EPanicBadPointers32,
sl@0
    98
    EPanicBadPointers33,
sl@0
    99
    EPanicBadPointers34,
sl@0
   100
    EPanicBadPointers35,
sl@0
   101
    EPanicBadPointers36,
sl@0
   102
    EPanicBadCalculation1,
sl@0
   103
    EPanicBadCalculation2,
sl@0
   104
    EPanicNumberOfBytesIsNotMultipleOfThree1,
sl@0
   105
    EPanicNumberOfBytesIsNotMultipleOfThree2,
sl@0
   106
    EPanicSingleShift2Expected,
sl@0
   107
    EPanicSingleShift3Expected
sl@0
   108
    };
sl@0
   109
sl@0
   110
LOCAL_C void Panic(TPanic aPanic)
sl@0
   111
    {
sl@0
   112
    User::Panic(KLitPanicText, aPanic);
sl@0
   113
    }
sl@0
   114
sl@0
   115
#endif
sl@0
   116
sl@0
   117
sl@0
   118
class CEucjpPackedConverterImpl : public CCharacterSetConverterPluginInterface
sl@0
   119
    {
sl@0
   120
sl@0
   121
public:
sl@0
   122
    virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
sl@0
   123
sl@0
   124
    virtual TInt ConvertFromUnicode(
sl@0
   125
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
sl@0
   126
        const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
sl@0
   127
        TDes8& aForeign,
sl@0
   128
        const TDesC16& aUnicode,
sl@0
   129
        CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
sl@0
   130
sl@0
   131
    virtual TInt ConvertToUnicode(
sl@0
   132
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
sl@0
   133
        TDes16& aUnicode,
sl@0
   134
        const TDesC8& aForeign,
sl@0
   135
        TInt& aState,
sl@0
   136
        TInt& aNumberOfUnconvertibleCharacters,
sl@0
   137
        TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
sl@0
   138
sl@0
   139
    virtual TBool IsInThisCharacterSetL(
sl@0
   140
        TBool& aSetToTrue,
sl@0
   141
        TInt& aConfidenceLevel,
sl@0
   142
        const TDesC8& aSample);
sl@0
   143
sl@0
   144
    static CEucjpPackedConverterImpl* NewL();
sl@0
   145
    virtual ~CEucjpPackedConverterImpl();
sl@0
   146
sl@0
   147
private:
sl@0
   148
    CEucjpPackedConverterImpl();
sl@0
   149
    void ConstructL();
sl@0
   150
sl@0
   151
    };
sl@0
   152
sl@0
   153
sl@0
   154
sl@0
   155
sl@0
   156
sl@0
   157
const TDesC8& CEucjpPackedConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
sl@0
   158
    {
sl@0
   159
    return KLit8EucJpPackedReplacementForUnconvertibleUnicodeCharacters;
sl@0
   160
    }
sl@0
   161
sl@0
   162
LOCAL_C void DummyConvertFromIntermediateBufferInPlace(TInt, TDes8&, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
   163
    {
sl@0
   164
    aNumberOfCharactersThatDroppedOut=0;
sl@0
   165
    }
sl@0
   166
sl@0
   167
LOCAL_C void ConvertFromJisX0208ToEucJpPackedInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
   168
    {
sl@0
   169
    aNumberOfCharactersThatDroppedOut=0;
sl@0
   170
    const TInt descriptorLength=aDescriptor.Length();
sl@0
   171
    __ASSERT_DEBUG(descriptorLength>aStartPositionInDescriptor, Panic(EPanicNothingToConvert1));
sl@0
   172
    __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%2==0, Panic(EPanicOddNumberOfBytes1));
sl@0
   173
    TUint8* pointerToCurrentByte=CONST_CAST(TUint8*, aDescriptor.Ptr());
sl@0
   174
    const TUint8* const pointerToLastByte=pointerToCurrentByte+(descriptorLength-1);
sl@0
   175
    pointerToCurrentByte+=aStartPositionInDescriptor;
sl@0
   176
    FOREVER
sl@0
   177
        {
sl@0
   178
        const TUint currentByte=*pointerToCurrentByte;
sl@0
   179
        __ASSERT_DEBUG((currentByte&0x80)==0, Panic(EPanicBadHighBit1));
sl@0
   180
        *pointerToCurrentByte=STATIC_CAST(TUint8, currentByte|0x80);
sl@0
   181
        __ASSERT_DEBUG(pointerToCurrentByte<=pointerToLastByte, Panic(EPanicBadPointers1));
sl@0
   182
        if (pointerToCurrentByte>=pointerToLastByte)
sl@0
   183
            {
sl@0
   184
            break;
sl@0
   185
            }
sl@0
   186
        ++pointerToCurrentByte;
sl@0
   187
        }
sl@0
   188
    }
sl@0
   189
sl@0
   190
LOCAL_C void ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
   191
    {
sl@0
   192
    TInt descriptorLength=aDescriptor.Length();
sl@0
   193
    __ASSERT_DEBUG(descriptorLength>aStartPositionInDescriptor, Panic(EPanicNothingToConvert2));
sl@0
   194
    aNumberOfCharactersThatDroppedOut=Max(0, (descriptorLength-aStartPositionInDescriptor)-((aDescriptor.MaxLength()-aStartPositionInDescriptor)/2));
sl@0
   195
    descriptorLength-=aNumberOfCharactersThatDroppedOut;
sl@0
   196
    __ASSERT_DEBUG(descriptorLength>=aStartPositionInDescriptor, Panic(EPanicBadCalculation1));
sl@0
   197
    if (descriptorLength<=aStartPositionInDescriptor)
sl@0
   198
        {
sl@0
   199
        aDescriptor.SetLength(descriptorLength);
sl@0
   200
        }
sl@0
   201
    else
sl@0
   202
        {
sl@0
   203
        TUint8* pointerToTargetByte=CONST_CAST(TUint8*, aDescriptor.Ptr()); // pointerToTargetByte is initialized properly when descriptorLength has been offset to the actual final length of aDescriptor
sl@0
   204
        const TUint8* const pointerToFirstByte=pointerToTargetByte+aStartPositionInDescriptor;
sl@0
   205
        const TUint8* pointerToSourceByte=pointerToTargetByte+(descriptorLength-1);
sl@0
   206
        descriptorLength=((descriptorLength-aStartPositionInDescriptor)*2)+aStartPositionInDescriptor;
sl@0
   207
        __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%2==0, Panic(EPanicOddNumberOfBytes2));
sl@0
   208
        aDescriptor.SetLength(descriptorLength);
sl@0
   209
        pointerToTargetByte+=descriptorLength-1; // pointerToTargetByte is is initialized properly here
sl@0
   210
        FOREVER
sl@0
   211
            {
sl@0
   212
            *pointerToTargetByte=*pointerToSourceByte;
sl@0
   213
            __ASSERT_DEBUG(pointerToTargetByte>pointerToFirstByte, Panic(EPanicBadPointers2));
sl@0
   214
            --pointerToTargetByte;
sl@0
   215
            *pointerToTargetByte=KSingleShift2;
sl@0
   216
            __ASSERT_DEBUG(pointerToTargetByte>=pointerToFirstByte, Panic(EPanicBadPointers3));
sl@0
   217
            if (pointerToTargetByte<=pointerToFirstByte)
sl@0
   218
                {
sl@0
   219
                break;
sl@0
   220
                }
sl@0
   221
            --pointerToTargetByte;
sl@0
   222
            __ASSERT_DEBUG(pointerToSourceByte>pointerToFirstByte, Panic(EPanicBadPointers4));
sl@0
   223
            --pointerToSourceByte;
sl@0
   224
            }
sl@0
   225
        __ASSERT_DEBUG(pointerToTargetByte==pointerToFirstByte, Panic(EPanicBadPointers5));
sl@0
   226
        __ASSERT_DEBUG(pointerToSourceByte==pointerToFirstByte, Panic(EPanicBadPointers6));
sl@0
   227
        }
sl@0
   228
    }
sl@0
   229
sl@0
   230
LOCAL_C void ConvertFromJisX0212ToEucJpPackedInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
   231
    {
sl@0
   232
    TInt descriptorLength=aDescriptor.Length();
sl@0
   233
    __ASSERT_DEBUG(descriptorLength>aStartPositionInDescriptor, Panic(EPanicNothingToConvert3));
sl@0
   234
    __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%2==0, Panic(EPanicOddNumberOfBytes3));
sl@0
   235
    aNumberOfCharactersThatDroppedOut=Max(0, ((descriptorLength-aStartPositionInDescriptor)/2)-((aDescriptor.MaxLength()-aStartPositionInDescriptor)/3));
sl@0
   236
    descriptorLength-=aNumberOfCharactersThatDroppedOut*2;
sl@0
   237
    __ASSERT_DEBUG(descriptorLength>=aStartPositionInDescriptor, Panic(EPanicBadCalculation2));
sl@0
   238
    if (descriptorLength<=aStartPositionInDescriptor)
sl@0
   239
        {
sl@0
   240
        aDescriptor.SetLength(descriptorLength);
sl@0
   241
        }
sl@0
   242
    else
sl@0
   243
        {
sl@0
   244
        __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%2==0, Panic(EPanicOddNumberOfBytes4));
sl@0
   245
        TUint8* pointerToTargetByte=CONST_CAST(TUint8*, aDescriptor.Ptr()); // pointerToTargetByte is initialized properly when descriptorLength has been offset to the actual final length of aDescriptor
sl@0
   246
        const TUint8* const pointerToFirstByte=pointerToTargetByte+aStartPositionInDescriptor;
sl@0
   247
        const TUint8* pointerToSourceByte=pointerToTargetByte+(descriptorLength-1);
sl@0
   248
        descriptorLength=(((descriptorLength-aStartPositionInDescriptor)*3)/2)+aStartPositionInDescriptor;
sl@0
   249
        __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%3==0, Panic(EPanicNumberOfBytesIsNotMultipleOfThree1));
sl@0
   250
        aDescriptor.SetLength(descriptorLength);
sl@0
   251
        pointerToTargetByte+=descriptorLength-1; // pointerToTargetByte is is initialized properly here
sl@0
   252
        FOREVER
sl@0
   253
            {
sl@0
   254
            __ASSERT_DEBUG((*pointerToSourceByte&0x80)==0, Panic(EPanicBadHighBit2));
sl@0
   255
            *pointerToTargetByte=STATIC_CAST(TUint8, *pointerToSourceByte|0x80);
sl@0
   256
            __ASSERT_DEBUG(pointerToTargetByte>pointerToFirstByte, Panic(EPanicBadPointers7));
sl@0
   257
            --pointerToTargetByte;
sl@0
   258
            __ASSERT_DEBUG(pointerToSourceByte>pointerToFirstByte, Panic(EPanicBadPointers8));
sl@0
   259
            --pointerToSourceByte;
sl@0
   260
            __ASSERT_DEBUG((*pointerToSourceByte&0x80)==0, Panic(EPanicBadHighBit3));
sl@0
   261
            *pointerToTargetByte=STATIC_CAST(TUint8, *pointerToSourceByte|0x80);
sl@0
   262
            __ASSERT_DEBUG(pointerToTargetByte>pointerToFirstByte, Panic(EPanicBadPointers9));
sl@0
   263
            --pointerToTargetByte;
sl@0
   264
            *pointerToTargetByte=KSingleShift3;
sl@0
   265
            __ASSERT_DEBUG(pointerToTargetByte>=pointerToFirstByte, Panic(EPanicBadPointers10));
sl@0
   266
            if (pointerToTargetByte<=pointerToFirstByte)
sl@0
   267
                {
sl@0
   268
                break;
sl@0
   269
                }
sl@0
   270
            --pointerToTargetByte;
sl@0
   271
            __ASSERT_DEBUG(pointerToSourceByte>pointerToFirstByte, Panic(EPanicBadPointers11));
sl@0
   272
            --pointerToSourceByte;
sl@0
   273
            }
sl@0
   274
        __ASSERT_DEBUG(pointerToTargetByte==pointerToFirstByte, Panic(EPanicBadPointers12));
sl@0
   275
        __ASSERT_DEBUG(pointerToSourceByte==pointerToFirstByte, Panic(EPanicBadPointers13));
sl@0
   276
        }
sl@0
   277
    }
sl@0
   278
sl@0
   279
TInt CEucjpPackedConverterImpl::ConvertFromUnicode(
sl@0
   280
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
sl@0
   281
        const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
sl@0
   282
        TDes8& aForeign,
sl@0
   283
        const TDesC16& aUnicode,
sl@0
   284
        CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
sl@0
   285
    {
sl@0
   286
    TInt ret = KErrNone;
sl@0
   287
    RArray<CnvUtilities::SCharacterSet> characterSets;
sl@0
   288
    if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
sl@0
   289
        {      
sl@0
   290
        CnvUtilities::SCharacterSet characterSet;
sl@0
   291
sl@0
   292
        characterSet.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   293
        characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
sl@0
   294
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   295
        ret |= characterSets.Append(characterSet);
sl@0
   296
        characterSet.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   297
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
sl@0
   298
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   299
        ret |= characterSets.Append(characterSet);
sl@0
   300
        characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
sl@0
   301
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
sl@0
   302
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   303
        ret |= characterSets.Append(characterSet);
sl@0
   304
        characterSet.iConversionData=&CnvJisX0212::ConversionData();
sl@0
   305
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
sl@0
   306
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   307
        ret |= characterSets.Append(characterSet);
sl@0
   308
sl@0
   309
        SetCharacterSetsForPictograph(characterSets, ECharsetEucJp);
sl@0
   310
        }
sl@0
   311
    else
sl@0
   312
        {            
sl@0
   313
        CnvUtilities::SCharacterSet characterSet;
sl@0
   314
        characterSet.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   315
        characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
sl@0
   316
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   317
        ret |= characterSets.Append(characterSet);
sl@0
   318
        characterSet.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   319
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
sl@0
   320
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   321
        ret |= characterSets.Append(characterSet);
sl@0
   322
        characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
sl@0
   323
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
sl@0
   324
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   325
        ret |= characterSets.Append(characterSet);
sl@0
   326
        characterSet.iConversionData=&CnvJisX0212::ConversionData();
sl@0
   327
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
sl@0
   328
        characterSet.iEscapeSequence=&KNullDesC8;
sl@0
   329
        ret |= characterSets.Append(characterSet);
sl@0
   330
        }
sl@0
   331
    __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret));
sl@0
   332
    TInt unconvert = CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array());
sl@0
   333
sl@0
   334
    characterSets.Close();
sl@0
   335
    return unconvert;
sl@0
   336
    }
sl@0
   337
sl@0
   338
LOCAL_C TInt NumberOfBytesAbleToConvertToJisRoman(const TDesC8& aDescriptor)
sl@0
   339
    {
sl@0
   340
    const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1;
sl@0
   341
    const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length();
sl@0
   342
    if (pointerToPreviousByte==pointerToLastByte)
sl@0
   343
        {
sl@0
   344
        return 0;
sl@0
   345
        }
sl@0
   346
    FOREVER
sl@0
   347
        {
sl@0
   348
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers14));
sl@0
   349
        const TUint currentByte=*(pointerToPreviousByte+1);
sl@0
   350
        if (currentByte&0x80)
sl@0
   351
            {
sl@0
   352
            break;
sl@0
   353
            }
sl@0
   354
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers15));
sl@0
   355
        ++pointerToPreviousByte;
sl@0
   356
        __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers16));
sl@0
   357
        if (pointerToPreviousByte>=pointerToLastByte)
sl@0
   358
            {
sl@0
   359
            break;
sl@0
   360
            }
sl@0
   361
        }
sl@0
   362
    return (pointerToPreviousByte+1)-aDescriptor.Ptr();
sl@0
   363
    }
sl@0
   364
sl@0
   365
LOCAL_C TInt NumberOfBytesAbleToConvertToJisX0208(const TDesC8& aDescriptor)
sl@0
   366
    {
sl@0
   367
    const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1;
sl@0
   368
    const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length();
sl@0
   369
    if (pointerToPreviousByte==pointerToLastByte)
sl@0
   370
        {
sl@0
   371
        return 0;
sl@0
   372
        }
sl@0
   373
    FOREVER
sl@0
   374
        {
sl@0
   375
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers17));
sl@0
   376
        TUint currentByte=*(pointerToPreviousByte+1);
sl@0
   377
        if (currentByte<0xa0)
sl@0
   378
            {
sl@0
   379
            break;
sl@0
   380
            }
sl@0
   381
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers18));
sl@0
   382
        if (pointerToLastByte-pointerToPreviousByte<2)
sl@0
   383
            {
sl@0
   384
            break;
sl@0
   385
            }
sl@0
   386
        ++pointerToPreviousByte;
sl@0
   387
        currentByte=*(pointerToPreviousByte+1);
sl@0
   388
        if (currentByte<0xa0)
sl@0
   389
            {
sl@0
   390
            return CCnvCharacterSetConverter::EErrorIllFormedInput;
sl@0
   391
            }
sl@0
   392
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers19));
sl@0
   393
        ++pointerToPreviousByte;
sl@0
   394
        __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers20));
sl@0
   395
        if (pointerToPreviousByte>=pointerToLastByte)
sl@0
   396
            {
sl@0
   397
            break;
sl@0
   398
            }
sl@0
   399
        }
sl@0
   400
    return (pointerToPreviousByte+1)-aDescriptor.Ptr();
sl@0
   401
    }
sl@0
   402
sl@0
   403
LOCAL_C TInt NumberOfBytesAbleToConvertToHalfWidthKatakana8(const TDesC8& aDescriptor)
sl@0
   404
    {
sl@0
   405
    const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1;
sl@0
   406
    const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length();
sl@0
   407
    if (pointerToPreviousByte==pointerToLastByte)
sl@0
   408
        {
sl@0
   409
        return 0;
sl@0
   410
        }
sl@0
   411
    FOREVER
sl@0
   412
        {
sl@0
   413
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers21));
sl@0
   414
        TUint currentByte=*(pointerToPreviousByte+1);
sl@0
   415
        if (currentByte!=KSingleShift2)
sl@0
   416
            {
sl@0
   417
            break;
sl@0
   418
            }
sl@0
   419
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers22));
sl@0
   420
        if (pointerToLastByte-pointerToPreviousByte<2)
sl@0
   421
            {
sl@0
   422
            break;
sl@0
   423
            }
sl@0
   424
        ++pointerToPreviousByte;
sl@0
   425
        currentByte=*(pointerToPreviousByte+1);
sl@0
   426
        if (currentByte<0xa0)
sl@0
   427
            {
sl@0
   428
            return CCnvCharacterSetConverter::EErrorIllFormedInput;
sl@0
   429
            }
sl@0
   430
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers23));
sl@0
   431
        ++pointerToPreviousByte;
sl@0
   432
        __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers24));
sl@0
   433
        if (pointerToPreviousByte>=pointerToLastByte)
sl@0
   434
            {
sl@0
   435
            break;
sl@0
   436
            }
sl@0
   437
        }
sl@0
   438
    return (pointerToPreviousByte+1)-aDescriptor.Ptr();
sl@0
   439
    }
sl@0
   440
sl@0
   441
LOCAL_C TInt NumberOfBytesAbleToConvertToJisX0212(const TDesC8& aDescriptor)
sl@0
   442
    {
sl@0
   443
    const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1;
sl@0
   444
    const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length();
sl@0
   445
    if (pointerToPreviousByte==pointerToLastByte)
sl@0
   446
        {
sl@0
   447
        return 0;
sl@0
   448
        }
sl@0
   449
    FOREVER
sl@0
   450
        {
sl@0
   451
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers25));
sl@0
   452
        TUint currentByte=*(pointerToPreviousByte+1);
sl@0
   453
        if (currentByte!=KSingleShift3)
sl@0
   454
            {
sl@0
   455
            break;
sl@0
   456
            }
sl@0
   457
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers26));
sl@0
   458
        if (pointerToLastByte-pointerToPreviousByte<3)
sl@0
   459
            {
sl@0
   460
            break;
sl@0
   461
            }
sl@0
   462
        ++pointerToPreviousByte;
sl@0
   463
        currentByte=*(pointerToPreviousByte+1);
sl@0
   464
        if (currentByte<0xa0)
sl@0
   465
            {
sl@0
   466
            return CCnvCharacterSetConverter::EErrorIllFormedInput;
sl@0
   467
            }
sl@0
   468
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers27));
sl@0
   469
        ++pointerToPreviousByte;
sl@0
   470
        currentByte=*(pointerToPreviousByte+1);
sl@0
   471
        if (currentByte<0xa0)
sl@0
   472
            {
sl@0
   473
            return CCnvCharacterSetConverter::EErrorIllFormedInput;
sl@0
   474
            }
sl@0
   475
        __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers28));
sl@0
   476
        ++pointerToPreviousByte;
sl@0
   477
        __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers29));
sl@0
   478
        if (pointerToPreviousByte>=pointerToLastByte)
sl@0
   479
            {
sl@0
   480
            break;
sl@0
   481
            }
sl@0
   482
        }
sl@0
   483
    return (pointerToPreviousByte+1)-aDescriptor.Ptr();
sl@0
   484
    }
sl@0
   485
sl@0
   486
LOCAL_C void DummyConvertToIntermediateBufferInPlace(TDes8&)
sl@0
   487
    {
sl@0
   488
    }
sl@0
   489
sl@0
   490
LOCAL_C void ConvertToJisX0208FromEucJpPackedInPlace(TDes8& aDescriptor)
sl@0
   491
    {
sl@0
   492
    const TInt descriptorLength=aDescriptor.Length();
sl@0
   493
    __ASSERT_DEBUG(descriptorLength>0, Panic(EPanicNothingToConvert4));
sl@0
   494
    __ASSERT_DEBUG(descriptorLength%2==0, Panic(EPanicOddNumberOfBytes5));
sl@0
   495
    TUint8* pointerToCurrentByte=CONST_CAST(TUint8*, aDescriptor.Ptr());
sl@0
   496
    const TUint8* const pointerToLastByte=pointerToCurrentByte+(descriptorLength-1);
sl@0
   497
    FOREVER
sl@0
   498
        {
sl@0
   499
        const TUint currentByte=*pointerToCurrentByte;
sl@0
   500
        __ASSERT_DEBUG(currentByte&0x80, Panic(EPanicBadHighBit4));
sl@0
   501
        *pointerToCurrentByte=STATIC_CAST(TUint8, currentByte&~0x80);
sl@0
   502
        __ASSERT_DEBUG(pointerToCurrentByte<=pointerToLastByte, Panic(EPanicBadPointers30));
sl@0
   503
        if (pointerToCurrentByte>=pointerToLastByte)
sl@0
   504
            {
sl@0
   505
            break;
sl@0
   506
            }
sl@0
   507
        ++pointerToCurrentByte;
sl@0
   508
        }
sl@0
   509
    }
sl@0
   510
sl@0
   511
LOCAL_C void ConvertToHalfWidthKatakana8FromEucJpPackedInPlace(TDes8& aDescriptor)
sl@0
   512
    {
sl@0
   513
    const TInt descriptorLength=aDescriptor.Length();
sl@0
   514
    __ASSERT_DEBUG(descriptorLength>0, Panic(EPanicNothingToConvert5));
sl@0
   515
    __ASSERT_DEBUG(descriptorLength%2==0, Panic(EPanicOddNumberOfBytes6));
sl@0
   516
    TUint8* pointerToTargetByte=CONST_CAST(TUint8*, aDescriptor.Ptr());
sl@0
   517
    const TUint8* pointerToSourceByte=pointerToTargetByte;
sl@0
   518
    const TUint8* const pointerToLastByte=pointerToSourceByte+(descriptorLength-1);
sl@0
   519
    FOREVER
sl@0
   520
        {
sl@0
   521
        __ASSERT_DEBUG(*pointerToSourceByte==KSingleShift2, Panic(EPanicSingleShift2Expected));
sl@0
   522
        __ASSERT_DEBUG(pointerToSourceByte<pointerToLastByte, Panic(EPanicBadPointers31));
sl@0
   523
        ++pointerToSourceByte;
sl@0
   524
        const TUint sourceByte=*pointerToSourceByte;
sl@0
   525
        __ASSERT_DEBUG(sourceByte&0x80, Panic(EPanicBadHighBit5));
sl@0
   526
        *pointerToTargetByte=STATIC_CAST(TUint8, sourceByte);
sl@0
   527
        __ASSERT_DEBUG(pointerToSourceByte<=pointerToLastByte, Panic(EPanicBadPointers32));
sl@0
   528
        if (pointerToSourceByte>=pointerToLastByte)
sl@0
   529
            {
sl@0
   530
            break;
sl@0
   531
            }
sl@0
   532
        ++pointerToSourceByte;
sl@0
   533
        ++pointerToTargetByte;
sl@0
   534
        }
sl@0
   535
    aDescriptor.SetLength(descriptorLength/2);
sl@0
   536
    }
sl@0
   537
sl@0
   538
LOCAL_C void ConvertToJisX0212FromEucJpPackedInPlace(TDes8& aDescriptor)
sl@0
   539
    {
sl@0
   540
    const TInt descriptorLength=aDescriptor.Length();
sl@0
   541
    __ASSERT_DEBUG(descriptorLength>0, Panic(EPanicNothingToConvert6));
sl@0
   542
    __ASSERT_DEBUG(descriptorLength%3==0, Panic(EPanicNumberOfBytesIsNotMultipleOfThree2));
sl@0
   543
    TUint8* pointerToTargetByte=CONST_CAST(TUint8*, aDescriptor.Ptr());
sl@0
   544
    const TUint8* pointerToSourceByte=pointerToTargetByte;
sl@0
   545
    const TUint8* const pointerToLastByte=pointerToSourceByte+(descriptorLength-1);
sl@0
   546
    FOREVER
sl@0
   547
        {
sl@0
   548
        __ASSERT_DEBUG(*pointerToSourceByte==KSingleShift3, Panic(EPanicSingleShift3Expected));
sl@0
   549
        __ASSERT_DEBUG(pointerToSourceByte<pointerToLastByte, Panic(EPanicBadPointers33));
sl@0
   550
        ++pointerToSourceByte;
sl@0
   551
        TUint sourceByte=*pointerToSourceByte;
sl@0
   552
        __ASSERT_DEBUG(sourceByte&0x80, Panic(EPanicBadHighBit6));
sl@0
   553
        *pointerToTargetByte=STATIC_CAST(TUint8, sourceByte&~0x80);
sl@0
   554
        __ASSERT_DEBUG(pointerToSourceByte<pointerToLastByte, Panic(EPanicBadPointers34));
sl@0
   555
        ++pointerToSourceByte;
sl@0
   556
        sourceByte=*pointerToSourceByte;
sl@0
   557
        __ASSERT_DEBUG(sourceByte&0x80, Panic(EPanicBadHighBit7));
sl@0
   558
        __ASSERT_DEBUG(pointerToTargetByte<pointerToLastByte, Panic(EPanicBadPointers35));
sl@0
   559
        ++pointerToTargetByte;
sl@0
   560
        *pointerToTargetByte=STATIC_CAST(TUint8, sourceByte&~0x80);
sl@0
   561
        __ASSERT_DEBUG(pointerToSourceByte<=pointerToLastByte, Panic(EPanicBadPointers36));
sl@0
   562
        if (pointerToSourceByte>=pointerToLastByte)
sl@0
   563
            {
sl@0
   564
            break;
sl@0
   565
            }
sl@0
   566
        ++pointerToSourceByte;
sl@0
   567
        ++pointerToTargetByte;
sl@0
   568
        }
sl@0
   569
    aDescriptor.SetLength((descriptorLength/3)*2);
sl@0
   570
    }
sl@0
   571
sl@0
   572
TInt CEucjpPackedConverterImpl::ConvertToUnicode(
sl@0
   573
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
sl@0
   574
        TDes16& aUnicode,
sl@0
   575
        const TDesC8& aForeign,
sl@0
   576
        TInt& /*aState*/,
sl@0
   577
        TInt& aNumberOfUnconvertibleCharacters,
sl@0
   578
        TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
sl@0
   579
    {
sl@0
   580
    TInt ret =KErrNone;
sl@0
   581
    RArray<CnvUtilities::SMethod> methods;
sl@0
   582
    if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
sl@0
   583
        {      
sl@0
   584
        CnvUtilities::SMethod method;
sl@0
   585
        SetMethodsForPictograph(methods, ECharsetEucJp);
sl@0
   586
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
sl@0
   587
        method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
sl@0
   588
        method.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   589
        method.iNumberOfBytesPerCharacter=1;
sl@0
   590
        method.iNumberOfCoreBytesPerCharacter=1;
sl@0
   591
        ret |= methods.Append(method);
sl@0
   592
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
sl@0
   593
        method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
sl@0
   594
        method.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   595
        method.iNumberOfBytesPerCharacter=2;
sl@0
   596
        method.iNumberOfCoreBytesPerCharacter=2;
sl@0
   597
        ret |= methods.Append(method);
sl@0
   598
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
sl@0
   599
        method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
sl@0
   600
        method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
sl@0
   601
        method.iNumberOfBytesPerCharacter=2;
sl@0
   602
        method.iNumberOfCoreBytesPerCharacter=1;
sl@0
   603
        ret |= methods.Append(method);
sl@0
   604
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
sl@0
   605
        method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
sl@0
   606
        method.iConversionData=&CnvJisX0212::ConversionData();
sl@0
   607
        method.iNumberOfBytesPerCharacter=3;
sl@0
   608
        method.iNumberOfCoreBytesPerCharacter=2;
sl@0
   609
        ret |= methods.Append(method);
sl@0
   610
        }
sl@0
   611
    else
sl@0
   612
        {
sl@0
   613
        CnvUtilities::SMethod method;
sl@0
   614
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
sl@0
   615
        method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
sl@0
   616
        method.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   617
        method.iNumberOfBytesPerCharacter=1;
sl@0
   618
        method.iNumberOfCoreBytesPerCharacter=1;
sl@0
   619
        ret |= methods.Append(method);
sl@0
   620
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
sl@0
   621
        method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
sl@0
   622
        method.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   623
        method.iNumberOfBytesPerCharacter=2;
sl@0
   624
        method.iNumberOfCoreBytesPerCharacter=2;
sl@0
   625
        ret |= methods.Append(method);
sl@0
   626
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
sl@0
   627
        method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
sl@0
   628
        method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
sl@0
   629
        method.iNumberOfBytesPerCharacter=2;
sl@0
   630
        method.iNumberOfCoreBytesPerCharacter=1;
sl@0
   631
        ret |= methods.Append(method);
sl@0
   632
        method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
sl@0
   633
        method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
sl@0
   634
        method.iConversionData=&CnvJisX0212::ConversionData();
sl@0
   635
        method.iNumberOfBytesPerCharacter=3;
sl@0
   636
        method.iNumberOfCoreBytesPerCharacter=2;
sl@0
   637
        ret |= methods.Append(method);
sl@0
   638
        }
sl@0
   639
    __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret));
sl@0
   640
    TInt unconvert = CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter, methods.Array());
sl@0
   641
sl@0
   642
    // The following is specific impelementation for brower.
sl@0
   643
    // If brower app calls this API, the yen sign code(0xA5)
sl@0
   644
    // must be converted to backslash code(0x5C).
sl@0
   645
    // Becasue Javascript supports backslash code ony.
sl@0
   646
    TBool browserProcess = (RProcess().SecureId().iId == KBrowserSecureId);
sl@0
   647
    if (browserProcess && aUnicode.Length() > 0)
sl@0
   648
        {
sl@0
   649
        const TUint16* pB = aUnicode.Ptr();
sl@0
   650
        const TUint16* pbase = pB;
sl@0
   651
        const TUint16* pE = pB + aUnicode.Length() -1;
sl@0
   652
        while (pE>=pbase)
sl@0
   653
            {
sl@0
   654
            if (*pbase == KCharacterCodeForYenSign)
sl@0
   655
                {
sl@0
   656
                aUnicode[pbase - pB] = KCharacterCodeForBackSlash;
sl@0
   657
                }
sl@0
   658
            pbase++;
sl@0
   659
            }
sl@0
   660
        }
sl@0
   661
sl@0
   662
    methods.Close();
sl@0
   663
    return unconvert;
sl@0
   664
    }
sl@0
   665
sl@0
   666
TBool CEucjpPackedConverterImpl::IsInThisCharacterSetL(
sl@0
   667
        TBool& aSetToTrue,
sl@0
   668
        TInt& aConfidenceLevel,
sl@0
   669
        const TDesC8& aSample)
sl@0
   670
    {
sl@0
   671
    aSetToTrue=ETrue;
sl@0
   672
    // check for the SS2 and SS3 which specifies Code Set 2 & 3 respectively from the Code space
sl@0
   673
    // between 00-7f only... then ambiguous
sl@0
   674
    aSetToTrue = ETrue;
sl@0
   675
    TInt sampleLength = aSample.Length();
sl@0
   676
    TInt eucjpPacked = 0;
sl@0
   677
    aConfidenceLevel = 0;
sl@0
   678
sl@0
   679
    for (TInt i = 0; i < sampleLength; ++i)
sl@0
   680
        {
sl@0
   681
        // Code set 1 JISX 0208 support
sl@0
   682
        TInt increment1 = i+1;
sl@0
   683
        if (increment1 >= sampleLength)
sl@0
   684
            break;
sl@0
   685
        if (((aSample[i] >= 0xa1) && (aSample[i] <= 0xfe)) &&
sl@0
   686
            ((aSample[increment1] >= 0xa1) && (aSample[increment1] <= 0xfe)))
sl@0
   687
            {
sl@0
   688
            eucjpPacked = eucjpPacked +2;
sl@0
   689
            i++;
sl@0
   690
            }
sl@0
   691
        // Single Shift 2 (SS2) sequence - Code Set 2
sl@0
   692
        if (aSample[i]==0x8e)
sl@0
   693
            {
sl@0
   694
            TInt increment1 = i+1;
sl@0
   695
            if (increment1 >= sampleLength)
sl@0
   696
                break;
sl@0
   697
            if ((aSample[increment1] >= 0xa1) && (aSample[increment1] <= 0xdf))
sl@0
   698
                {
sl@0
   699
                eucjpPacked = eucjpPacked+2;
sl@0
   700
                i++;
sl@0
   701
                }
sl@0
   702
            else
sl@0
   703
                {
sl@0
   704
                eucjpPacked = 0;
sl@0
   705
                break;
sl@0
   706
                }
sl@0
   707
            }
sl@0
   708
        // Single Shift 3 (SS3) sequence - Code Set 3
sl@0
   709
        if (aSample[i]==0x8f)
sl@0
   710
            {
sl@0
   711
            TInt increment1 = i+1;
sl@0
   712
            TInt increment2 = i+2;
sl@0
   713
            if ((increment1 >= sampleLength) || (increment2 >= sampleLength))
sl@0
   714
                break;
sl@0
   715
            if (((aSample[increment1] >= 0xa1) && (aSample[increment1] <= 0xfe)) &&
sl@0
   716
                ((aSample[increment2] >= 0xa1) && (aSample[increment2] <= 0xfe)))
sl@0
   717
                {
sl@0
   718
                eucjpPacked = eucjpPacked +3;
sl@0
   719
                i+=2;
sl@0
   720
                }
sl@0
   721
            else
sl@0
   722
                {
sl@0
   723
                eucjpPacked =0;
sl@0
   724
                break;
sl@0
   725
                }
sl@0
   726
            }
sl@0
   727
        }
sl@0
   728
    if (eucjpPacked)
sl@0
   729
        aConfidenceLevel = (eucjpPacked*100)/sampleLength;
sl@0
   730
    else
sl@0
   731
        aConfidenceLevel = 0;
sl@0
   732
    aConfidenceLevel=(aConfidenceLevel >100)?100:aConfidenceLevel;
sl@0
   733
    return ETrue;
sl@0
   734
    }
sl@0
   735
sl@0
   736
CEucjpPackedConverterImpl* CEucjpPackedConverterImpl::NewL()
sl@0
   737
    {
sl@0
   738
    CEucjpPackedConverterImpl* self = new(ELeave) CEucjpPackedConverterImpl();
sl@0
   739
    CleanupStack::PushL(self);
sl@0
   740
    self->ConstructL();
sl@0
   741
    CleanupStack::Pop(self);
sl@0
   742
    return self;
sl@0
   743
    }
sl@0
   744
sl@0
   745
CEucjpPackedConverterImpl::~CEucjpPackedConverterImpl()
sl@0
   746
    {
sl@0
   747
    FeatureManager::UnInitializeLib();    
sl@0
   748
    }
sl@0
   749
sl@0
   750
CEucjpPackedConverterImpl::CEucjpPackedConverterImpl()
sl@0
   751
    {
sl@0
   752
    }
sl@0
   753
sl@0
   754
void CEucjpPackedConverterImpl::ConstructL()
sl@0
   755
    {
sl@0
   756
    FeatureManager::InitializeLibL();
sl@0
   757
    }
sl@0
   758
sl@0
   759
const TImplementationProxy ImplementationTable[] =
sl@0
   760
    {
sl@0
   761
#ifdef S60_TEST
sl@0
   762
    IMPLEMENTATION_PROXY_ENTRY(0x01000005,CEucjpPackedConverterImpl::NewL)
sl@0
   763
#else
sl@0
   764
    IMPLEMENTATION_PROXY_ENTRY(0x10006067,CEucjpPackedConverterImpl::NewL)
sl@0
   765
#endif
sl@0
   766
    };
sl@0
   767
sl@0
   768
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   769
    {
sl@0
   770
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   771
sl@0
   772
    return ImplementationTable;
sl@0
   773
    }
sl@0
   774