os/textandloc/charconvfw/charconvplugins/src/plugins/ISO2022JP_2.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 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
#include "featmgr/featmgr.h" 
sl@0
    20
sl@0
    21
#include <e32std.h>
sl@0
    22
#include <charconv.h>
sl@0
    23
#include <convutils.h>
sl@0
    24
#include "jisbase.h"
sl@0
    25
#include "jisx0201.h"
sl@0
    26
#include "jisx0208.h"
sl@0
    27
#include <ecom/implementationproxy.h>
sl@0
    28
#include "charactersetconverter.h"
sl@0
    29
sl@0
    30
sl@0
    31
_LIT8(KLit8EscapeSequenceForJisRoman, "\x1b\x28\x4a");
sl@0
    32
_LIT8(KLit8EscapeSequenceForAscii, "\x1b\x28\x42");     
sl@0
    33
_LIT8(KLit8EscapeSequenceForJisX0208_1983, "\x1b\x24\x42");
sl@0
    34
//_LIT8(KLit8EscapeSequenceForJisC6226_1978, "\x1b\x24\x40");
sl@0
    35
//_LIT8(KLit8EscapeSequenceForJisX0212_1990, "\x1b\x24\x28\x44"); 
sl@0
    36
//_LIT8(KLit8EscapeSequenceForHalfWidthKatakana, "\x1b\x28\x49");
sl@0
    37
_LIT8(KLit8Iso2022JpReplacementForUnconvertibleUnicodeCharacters, "\x1b\x24\x42\x21\x29"); // fullwidth question mark
sl@0
    38
sl@0
    39
sl@0
    40
class CISO2022JPConverterImpl : public CCharacterSetConverterPluginInterface
sl@0
    41
    {
sl@0
    42
sl@0
    43
public:
sl@0
    44
    virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
sl@0
    45
sl@0
    46
    virtual TInt ConvertFromUnicode(
sl@0
    47
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    48
        const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
sl@0
    49
        TDes8& aForeign, 
sl@0
    50
        const TDesC16& aUnicode, 
sl@0
    51
        CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
sl@0
    52
sl@0
    53
    virtual TInt ConvertToUnicode(
sl@0
    54
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
    55
        TDes16& aUnicode, 
sl@0
    56
        const TDesC8& aForeign, 
sl@0
    57
        TInt& aState, 
sl@0
    58
        TInt& aNumberOfUnconvertibleCharacters, 
sl@0
    59
        TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
sl@0
    60
sl@0
    61
    virtual TBool IsInThisCharacterSetL(
sl@0
    62
        TBool& aSetToTrue, 
sl@0
    63
        TInt& aConfidenceLevel, 
sl@0
    64
        const TDesC8& aSample);
sl@0
    65
sl@0
    66
    static CISO2022JPConverterImpl* NewL();
sl@0
    67
    virtual ~CISO2022JPConverterImpl();
sl@0
    68
sl@0
    69
private:
sl@0
    70
    CISO2022JPConverterImpl();
sl@0
    71
    void ConstructL();
sl@0
    72
sl@0
    73
    };
sl@0
    74
sl@0
    75
sl@0
    76
sl@0
    77
const TDesC8& CISO2022JPConverterImpl::ReplacementForUnconvertibleUnicodeCharacters()
sl@0
    78
    {
sl@0
    79
    return KLit8Iso2022JpReplacementForUnconvertibleUnicodeCharacters;
sl@0
    80
    }
sl@0
    81
sl@0
    82
LOCAL_C void ConvertFromJisRomanToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
    83
    {
sl@0
    84
    CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisRoman, 1);
sl@0
    85
    }
sl@0
    86
sl@0
    87
LOCAL_C void ConvertFromAsciiToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
    88
    {
sl@0
    89
    CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForAscii, 1);
sl@0
    90
    }
sl@0
    91
sl@0
    92
LOCAL_C void ConvertFromJisX0208ToJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
    93
    {
sl@0
    94
    CnvUtilities::ConvertFromIntermediateBufferInPlace(aStartPositionInDescriptor, aDescriptor, aNumberOfCharactersThatDroppedOut, KLit8EscapeSequenceForJisX0208_1983, 2);
sl@0
    95
    }
sl@0
    96
sl@0
    97
struct TConvTblFromHalfKanaToFullKana
sl@0
    98
    {
sl@0
    99
    TUint8  iHalfKana;
sl@0
   100
    TUint8  iHalfKanaMark;
sl@0
   101
    TUint16 iFullKana;
sl@0
   102
    };
sl@0
   103
sl@0
   104
LOCAL_D const TConvTblFromHalfKanaToFullKana convTblFromHalfKanaToFullKana[]=
sl@0
   105
    {
sl@0
   106
        { 0xA1, 0x00, 0x2123 },     // IDEOGRAPHIC FULL STOP
sl@0
   107
        { 0xA2, 0x00, 0x2156 },     // LEFT CORNER BRACKET
sl@0
   108
        { 0xA3, 0x00, 0x2157 },     // RIGHT CORNER BRACKET
sl@0
   109
        { 0xA4, 0x00, 0x2122 },     // IDEOGRAPHIC COMMA
sl@0
   110
        { 0xA5, 0x00, 0x2126 },     // KATAKANA MIDDLE DOT
sl@0
   111
        { 0xA6, 0x00, 0x2572 },     // KATAKANA LETTER WO
sl@0
   112
        { 0xA7, 0x00, 0x2521 },     // KATAKANA LETTER SMALL A
sl@0
   113
        { 0xA8, 0x00, 0x2523 },     // KATAKANA LETTER SMALL I
sl@0
   114
        { 0xA9, 0x00, 0x2525 },     // KATAKANA LETTER SMALL U
sl@0
   115
        { 0xAA, 0x00, 0x2527 },     // KATAKANA LETTER SMALL E
sl@0
   116
        { 0xAB, 0x00, 0x2529 },     // KATAKANA LETTER SMALL O
sl@0
   117
        { 0xAC, 0x00, 0x2563 },     // KATAKANA LETTER SMALL YA
sl@0
   118
        { 0xAD, 0x00, 0x2565 },     // KATAKANA LETTER SMALL YU
sl@0
   119
        { 0xAE, 0x00, 0x2567 },     // KATAKANA LETTER SMALL YO
sl@0
   120
        { 0xAF, 0x00, 0x2543 },     // KATAKANA LETTER SMALL TU
sl@0
   121
        { 0xB0, 0x00, 0x213C },     // KATAKANA-HIRAGANA PROLONGED SOUND MARK
sl@0
   122
        { 0xB1, 0x00, 0x2522 },     // KATAKANA LETTER A
sl@0
   123
        { 0xB2, 0x00, 0x2524 },     // KATAKANA LETTER I
sl@0
   124
        { 0xB3, 0x00, 0x2526 },     // KATAKANA LETTER U
sl@0
   125
        { 0xB3, 0xDE, 0x2574 },     // KATAKANA LETTER VU
sl@0
   126
        { 0xB4, 0x00, 0x2528 },     // KATAKANA LETTER E
sl@0
   127
        { 0xB5, 0x00, 0x252A },     // KATAKANA LETTER O
sl@0
   128
        { 0xB6, 0x00, 0x252B },     // KATAKANA LETTER KA
sl@0
   129
        { 0xB6, 0xDE, 0x252C },     // KATAKANA LETTER GA
sl@0
   130
        { 0xB7, 0x00, 0x252D },     // KATAKANA LETTER KI
sl@0
   131
        { 0xB7, 0xDE, 0x252E },     // KATAKANA LETTER GI
sl@0
   132
        { 0xB8, 0x00, 0x252F },     // KATAKANA LETTER KU
sl@0
   133
        { 0xB8, 0xDE, 0x2530 },     // KATAKANA LETTER GU
sl@0
   134
        { 0xB9, 0x00, 0x2531 },     // KATAKANA LETTER KE
sl@0
   135
        { 0xB9, 0xDE, 0x2532 },     // KATAKANA LETTER GE
sl@0
   136
        { 0xBA, 0x00, 0x2533 },     // KATAKANA LETTER KO
sl@0
   137
        { 0xBA, 0xDE, 0x2534 },     // KATAKANA LETTER GO
sl@0
   138
        { 0xBB, 0x00, 0x2535 },     // KATAKANA LETTER SA
sl@0
   139
        { 0xBB, 0xDE, 0x2536 },     // KATAKANA LETTER ZA
sl@0
   140
        { 0xBC, 0x00, 0x2537 },     // KATAKANA LETTER SI
sl@0
   141
        { 0xBC, 0xDE, 0x2538 },     // KATAKANA LETTER ZI
sl@0
   142
        { 0xBD, 0x00, 0x2539 },     // KATAKANA LETTER SU
sl@0
   143
        { 0xBD, 0xDE, 0x253A },     // KATAKANA LETTER ZU
sl@0
   144
        { 0xBE, 0x00, 0x253B },     // KATAKANA LETTER SE
sl@0
   145
        { 0xBE, 0xDE, 0x253C },     // KATAKANA LETTER ZE
sl@0
   146
        { 0xBF, 0x00, 0x253D },     // KATAKANA LETTER SO
sl@0
   147
        { 0xBF, 0xDE, 0x253E },     // KATAKANA LETTER ZO
sl@0
   148
        { 0xC0, 0x00, 0x253F },     // KATAKANA LETTER TA
sl@0
   149
        { 0xC0, 0xDE, 0x2540 },     // KATAKANA LETTER DA
sl@0
   150
        { 0xC1, 0x00, 0x2541 },     // KATAKANA LETTER TI
sl@0
   151
        { 0xC1, 0xDE, 0x2542 },     // KATAKANA LETTER DI
sl@0
   152
        { 0xC2, 0x00, 0x2544 },     // KATAKANA LETTER TU
sl@0
   153
        { 0xC2, 0xDE, 0x2545 },     // KATAKANA LETTER DU
sl@0
   154
        { 0xC3, 0x00, 0x2546 },     // KATAKANA LETTER TE
sl@0
   155
        { 0xC3, 0xDE, 0x2547 },     // KATAKANA LETTER DE
sl@0
   156
        { 0xC4, 0x00, 0x2548 },     // KATAKANA LETTER TO
sl@0
   157
        { 0xC4, 0xDE, 0x2549 },     // KATAKANA LETTER DO
sl@0
   158
        { 0xC5, 0x00, 0x254A },     // KATAKANA LETTER NA
sl@0
   159
        { 0xC6, 0x00, 0x254B },     // KATAKANA LETTER NI
sl@0
   160
        { 0xC7, 0x00, 0x254C },     // KATAKANA LETTER NU
sl@0
   161
        { 0xC8, 0x00, 0x254D },     // KATAKANA LETTER NE
sl@0
   162
        { 0xC9, 0x00, 0x254E },     // KATAKANA LETTER NO
sl@0
   163
        { 0xCA, 0x00, 0x254F },     // KATAKANA LETTER HA
sl@0
   164
        { 0xCA, 0xDE, 0x2550 },     // KATAKANA LETTER BA
sl@0
   165
        { 0xCA, 0xDF, 0x2551 },     // KATAKANA LETTER PA
sl@0
   166
        { 0xCB, 0x00, 0x2552 },     // KATAKANA LETTER HI
sl@0
   167
        { 0xCB, 0xDE, 0x2553 },     // KATAKANA LETTER BI
sl@0
   168
        { 0xCB, 0xDF, 0x2554 },     // KATAKANA LETTER PI
sl@0
   169
        { 0xCC, 0x00, 0x2555 },     // KATAKANA LETTER HU
sl@0
   170
        { 0xCC, 0xDE, 0x2556 },     // KATAKANA LETTER BU
sl@0
   171
        { 0xCC, 0xDF, 0x2557 },     // KATAKANA LETTER PU
sl@0
   172
        { 0xCD, 0x00, 0x2558 },     // KATAKANA LETTER HE
sl@0
   173
        { 0xCD, 0xDE, 0x2559 },     // KATAKANA LETTER BE
sl@0
   174
        { 0xCD, 0xDF, 0x255A },     // KATAKANA LETTER PE
sl@0
   175
        { 0xCE, 0x00, 0x255B },     // KATAKANA LETTER HO
sl@0
   176
        { 0xCE, 0xDE, 0x255C },     // KATAKANA LETTER BO
sl@0
   177
        { 0xCE, 0xDF, 0x255D },     // KATAKANA LETTER PO
sl@0
   178
        { 0xCF, 0x00, 0x255E },     // KATAKANA LETTER MA
sl@0
   179
        { 0xD0, 0x00, 0x255F },     // KATAKANA LETTER MI
sl@0
   180
        { 0xD1, 0x00, 0x2560 },     // KATAKANA LETTER MU
sl@0
   181
        { 0xD2, 0x00, 0x2561 },     // KATAKANA LETTER ME
sl@0
   182
        { 0xD3, 0x00, 0x2562 },     // KATAKANA LETTER MO
sl@0
   183
        { 0xD4, 0x00, 0x2564 },     // KATAKANA LETTER YA
sl@0
   184
        { 0xD5, 0x00, 0x2566 },     // KATAKANA LETTER YU
sl@0
   185
        { 0xD6, 0x00, 0x2568 },     // KATAKANA LETTER YO
sl@0
   186
        { 0xD7, 0x00, 0x2569 },     // KATAKANA LETTER RA
sl@0
   187
        { 0xD8, 0x00, 0x256A },     // KATAKANA LETTER RI
sl@0
   188
        { 0xD9, 0x00, 0x256B },     // KATAKANA LETTER RU
sl@0
   189
        { 0xDA, 0x00, 0x256C },     // KATAKANA LETTER RE
sl@0
   190
        { 0xDB, 0x00, 0x256D },     // KATAKANA LETTER RO
sl@0
   191
        { 0xDC, 0x00, 0x256F },     // KATAKANA LETTER WA
sl@0
   192
        { 0xDD, 0x00, 0x2573 },     // KATAKANA LETTER N
sl@0
   193
        { 0xDE, 0x00, 0x212B },     // HALFWIDTH KATAKANA VOICED SOUND MARK
sl@0
   194
        { 0xDF, 0x00, 0x212C }      // HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
sl@0
   195
    };
sl@0
   196
#define ARRAY_LENGTH(aArray) (sizeof(aArray)/sizeof((aArray)[0]))
sl@0
   197
sl@0
   198
LOCAL_C void ConvertFromHalfKatakanaToFullKatakana(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut)
sl@0
   199
    {
sl@0
   200
    // half-width Katakana is 1-byte, but full-width Katakana is 2-bytes.
sl@0
   201
    TInt convertlength = aDescriptor.Length()-aStartPositionInDescriptor;
sl@0
   202
    TInt numberOfMarkChar = 0;
sl@0
   203
    HBufC8* hBuf = HBufC8::New(convertlength*2);
sl@0
   204
    if (hBuf)
sl@0
   205
        {
sl@0
   206
        TPtr8 ptr = hBuf->Des();
sl@0
   207
        for (TInt i=aStartPositionInDescriptor; i < aDescriptor.Length(); i++)
sl@0
   208
            {
sl@0
   209
            const TUint8 convchar = (TUint8)(aDescriptor[i]|0x80);
sl@0
   210
            const TUint8 convnextchar = (TUint8)((aDescriptor.Length() > (i+1))?
sl@0
   211
                        (aDescriptor[i+1]|0x80) : TUint8(0x00));
sl@0
   212
            const TConvTblFromHalfKanaToFullKana* curTbl = &(convTblFromHalfKanaToFullKana[0]);
sl@0
   213
            for (TUint j=0; j < ARRAY_LENGTH(convTblFromHalfKanaToFullKana); curTbl++, j++)
sl@0
   214
                {
sl@0
   215
                if (convchar == curTbl->iHalfKana)
sl@0
   216
                    {
sl@0
   217
                    for (TInt k=0; (convchar == (curTbl+k)->iHalfKana); k++)
sl@0
   218
                        {
sl@0
   219
                        if (convnextchar == (curTbl+k)->iHalfKanaMark)
sl@0
   220
                            {
sl@0
   221
                            curTbl += k;
sl@0
   222
                            if (convnextchar == 0xDE || convnextchar == 0xDF)
sl@0
   223
                                {
sl@0
   224
                                i++;
sl@0
   225
                                numberOfMarkChar++;
sl@0
   226
                                }
sl@0
   227
                            break;
sl@0
   228
                            }
sl@0
   229
                        }
sl@0
   230
                    // set to buffer each 8 bit
sl@0
   231
                    const TUint8 highbit = (TUint8)(curTbl->iFullKana>>8);
sl@0
   232
                    const TUint8 lowbit = (TUint8)(curTbl->iFullKana|0xff00);
sl@0
   233
                    ptr.Append(highbit);
sl@0
   234
                    ptr.Append(lowbit);
sl@0
   235
                    break;
sl@0
   236
                    }
sl@0
   237
                }
sl@0
   238
            }
sl@0
   239
        // add ESC code
sl@0
   240
        CnvUtilities::ConvertFromIntermediateBufferInPlace(
sl@0
   241
                            aStartPositionInDescriptor, 
sl@0
   242
                            aDescriptor, aNumberOfCharactersThatDroppedOut, 
sl@0
   243
                            KLit8EscapeSequenceForJisX0208_1983, 1);
sl@0
   244
        if (!aNumberOfCharactersThatDroppedOut)
sl@0
   245
            {
sl@0
   246
            // delete half-width katakana
sl@0
   247
            aDescriptor.Delete(aStartPositionInDescriptor 
sl@0
   248
                                + KLit8EscapeSequenceForJisX0208_1983().Length(),
sl@0
   249
                               convertlength);
sl@0
   250
sl@0
   251
            TInt freelength = aDescriptor.MaxLength() - aDescriptor.Length();
sl@0
   252
            TInt copylength = ptr.Length();
sl@0
   253
            if (copylength > freelength)
sl@0
   254
                {
sl@0
   255
                copylength = freelength - (freelength%2);
sl@0
   256
                }
sl@0
   257
            if (copylength > 0)
sl@0
   258
                {
sl@0
   259
                // not convert, because there is no enough buffer
sl@0
   260
                aDescriptor.Append(ptr.Ptr(), copylength);
sl@0
   261
                aNumberOfCharactersThatDroppedOut=(convertlength-numberOfMarkChar) - (copylength/2);
sl@0
   262
                }
sl@0
   263
            else
sl@0
   264
                {
sl@0
   265
                // not convert, because there is no enough buffer.
sl@0
   266
                aNumberOfCharactersThatDroppedOut=convertlength;
sl@0
   267
                aDescriptor.SetLength(aStartPositionInDescriptor);
sl@0
   268
                }
sl@0
   269
            }
sl@0
   270
        delete hBuf;
sl@0
   271
        }
sl@0
   272
    else
sl@0
   273
        {
sl@0
   274
        // not convert, because there is no heap area.
sl@0
   275
        aNumberOfCharactersThatDroppedOut=convertlength;
sl@0
   276
        aDescriptor.SetLength(aStartPositionInDescriptor);
sl@0
   277
        }
sl@0
   278
    }
sl@0
   279
sl@0
   280
TInt CISO2022JPConverterImpl::ConvertFromUnicode(
sl@0
   281
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
   282
        const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
sl@0
   283
        TDes8& aForeign, 
sl@0
   284
        const TDesC16& aUnicode, 
sl@0
   285
        CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
sl@0
   286
    {
sl@0
   287
    TInt ret = KErrNone;
sl@0
   288
    RArray<CnvUtilities::SCharacterSet> characterSets;
sl@0
   289
    if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
sl@0
   290
        {        
sl@0
   291
        CnvUtilities::SCharacterSet characterSet;
sl@0
   292
        characterSet.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   293
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
sl@0
   294
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
sl@0
   295
        ret |= characterSets.Append(characterSet);
sl@0
   296
        characterSet.iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
sl@0
   297
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
sl@0
   298
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForAscii;
sl@0
   299
        ret |= characterSets.Append(characterSet);
sl@0
   300
        characterSet.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   301
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
sl@0
   302
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
sl@0
   303
        ret |= characterSets.Append(characterSet);
sl@0
   304
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
sl@0
   305
        characterSet.iConversionData=&CnvJisBase::HalfWidthKatakana7ConversionData();
sl@0
   306
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfKatakanaToFullKatakana;
sl@0
   307
        ret |= characterSets.Append(characterSet);
sl@0
   308
sl@0
   309
        SetCharacterSetsForPictograph(characterSets);
sl@0
   310
        }
sl@0
   311
    else
sl@0
   312
        {            
sl@0
   313
        CnvUtilities::SCharacterSet characterSet;
sl@0
   314
        characterSet.iConversionData=&CCnvCharacterSetConverter::AsciiConversionData();
sl@0
   315
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromAsciiToJisInPlace;
sl@0
   316
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForAscii;
sl@0
   317
        ret |= characterSets.Append(characterSet);
sl@0
   318
        characterSet.iConversionData=&CnvJisRoman::ConversionData();
sl@0
   319
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisRomanToJisInPlace;
sl@0
   320
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisRoman;
sl@0
   321
        ret |= characterSets.Append(characterSet);
sl@0
   322
        characterSet.iConversionData=&CnvJisX0208::ConversionData();
sl@0
   323
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToJisInPlace;
sl@0
   324
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
sl@0
   325
        ret |= characterSets.Append(characterSet);
sl@0
   326
        characterSet.iEscapeSequence=&KLit8EscapeSequenceForJisX0208_1983;
sl@0
   327
        characterSet.iConversionData=&CnvJisBase::HalfWidthKatakana7ConversionData();
sl@0
   328
        characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfKatakanaToFullKatakana;
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
    TUint notUsed;
sl@0
   333
//S60 30    TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet;
sl@0
   334
    TUint inputConversionFlags=CCnvCharacterSetConverter::EInputConversionFlagMustEndInDefaultCharacterSet |
sl@0
   335
                               CCnvCharacterSetConverter::EInputConversionFlagAssumeStartInDefaultCharacterSet;
sl@0
   336
    TInt unconvert = CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters,
sl@0
   337
                                                      aReplacementForUnconvertibleUnicodeCharacters, 
sl@0
   338
                                                      aForeign, 
sl@0
   339
                                                      aUnicode, 
sl@0
   340
                                                      aIndicesOfUnconvertibleCharacters, 
sl@0
   341
                                                      characterSets.Array(),
sl@0
   342
                                                      notUsed,
sl@0
   343
                                                      inputConversionFlags);
sl@0
   344
        
sl@0
   345
    characterSets.Close();
sl@0
   346
sl@0
   347
    return unconvert;
sl@0
   348
    }
sl@0
   349
sl@0
   350
sl@0
   351
TInt CISO2022JPConverterImpl::ConvertToUnicode(
sl@0
   352
        CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
sl@0
   353
        TDes16& aUnicode, 
sl@0
   354
        const TDesC8& aForeign, 
sl@0
   355
        TInt& aState, 
sl@0
   356
        TInt& aNumberOfUnconvertibleCharacters, 
sl@0
   357
        TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
sl@0
   358
    {
sl@0
   359
    return CnvJisBase::ConvertToUnicode(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aState, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter);
sl@0
   360
    }
sl@0
   361
sl@0
   362
TBool CISO2022JPConverterImpl::IsInThisCharacterSetL(
sl@0
   363
        TBool& aSetToTrue, 
sl@0
   364
        TInt& aConfidenceLevel, 
sl@0
   365
        const TDesC8& aSample)
sl@0
   366
    {
sl@0
   367
    aSetToTrue=ETrue;
sl@0
   368
    CnvJisBase::IsCharacterJISBased(aConfidenceLevel, aSample);
sl@0
   369
    return ETrue;
sl@0
   370
    }
sl@0
   371
sl@0
   372
CISO2022JPConverterImpl* CISO2022JPConverterImpl::NewL()
sl@0
   373
    {
sl@0
   374
    CISO2022JPConverterImpl* self = new(ELeave) CISO2022JPConverterImpl();
sl@0
   375
    CleanupStack::PushL(self);
sl@0
   376
    self->ConstructL();
sl@0
   377
    CleanupStack::Pop(self);
sl@0
   378
    return self;
sl@0
   379
    }
sl@0
   380
sl@0
   381
CISO2022JPConverterImpl::~CISO2022JPConverterImpl()
sl@0
   382
    {
sl@0
   383
    FeatureManager::UnInitializeLib();
sl@0
   384
    }
sl@0
   385
sl@0
   386
CISO2022JPConverterImpl::CISO2022JPConverterImpl()
sl@0
   387
    {
sl@0
   388
    }
sl@0
   389
sl@0
   390
void CISO2022JPConverterImpl::ConstructL()
sl@0
   391
    {
sl@0
   392
    FeatureManager::InitializeLibL();
sl@0
   393
    }
sl@0
   394
sl@0
   395
const TImplementationProxy ImplementationTable[] = 
sl@0
   396
    {
sl@0
   397
#ifdef S60_TEST
sl@0
   398
    IMPLEMENTATION_PROXY_ENTRY(0x01000006,  CISO2022JPConverterImpl::NewL)
sl@0
   399
#else
sl@0
   400
    IMPLEMENTATION_PROXY_ENTRY(0x100066A0,  CISO2022JPConverterImpl::NewL)
sl@0
   401
#endif        
sl@0
   402
    };
sl@0
   403
sl@0
   404
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   405
    {
sl@0
   406
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   407
sl@0
   408
    return ImplementationTable;
sl@0
   409
    }
sl@0
   410