charconvfw/charconvplugins/src/plugins/EUCJP_PACKED_2.CPP
branchRCL_3
changeset 17 336bee5c2d35
parent 16 748ec5531811
equal deleted inserted replaced
16:748ec5531811 17:336bee5c2d35
   281         const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
   281         const TDesC8& aReplacementForUnconvertibleUnicodeCharacters,
   282         TDes8& aForeign,
   282         TDes8& aForeign,
   283         const TDesC16& aUnicode,
   283         const TDesC16& aUnicode,
   284         CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
   284         CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
   285     {
   285     {
   286     TInt ret = KErrNone;
       
   287     RArray<CnvUtilities::SCharacterSet> characterSets;
   286     RArray<CnvUtilities::SCharacterSet> characterSets;
   288     if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
   287     if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
   289         {      
   288         {      
   290         CnvUtilities::SCharacterSet characterSet;
   289         CnvUtilities::SCharacterSet characterSet;
   291 
   290 
   292         characterSet.iConversionData=&CnvJisRoman::ConversionData();
   291         characterSet.iConversionData=&CnvJisRoman::ConversionData();
   293         characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
   292         characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
   294         characterSet.iEscapeSequence=&KNullDesC8;
   293         characterSet.iEscapeSequence=&KNullDesC8;
   295         ret |= characterSets.Append(characterSet);
   294         characterSets.Append(characterSet);
   296         characterSet.iConversionData=&CnvJisX0208::ConversionData();
   295         characterSet.iConversionData=&CnvJisX0208::ConversionData();
   297         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
   296         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
   298         characterSet.iEscapeSequence=&KNullDesC8;
   297         characterSet.iEscapeSequence=&KNullDesC8;
   299         ret |= characterSets.Append(characterSet);
   298         characterSets.Append(characterSet);
   300         characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   299         characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   301         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
   300         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
   302         characterSet.iEscapeSequence=&KNullDesC8;
   301         characterSet.iEscapeSequence=&KNullDesC8;
   303         ret |= characterSets.Append(characterSet);
   302         characterSets.Append(characterSet);
   304         characterSet.iConversionData=&CnvJisX0212::ConversionData();
   303         characterSet.iConversionData=&CnvJisX0212::ConversionData();
   305         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
   304         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
   306         characterSet.iEscapeSequence=&KNullDesC8;
   305         characterSet.iEscapeSequence=&KNullDesC8;
   307         ret |= characterSets.Append(characterSet);
   306         characterSets.Append(characterSet);
   308 
   307 
   309         SetCharacterSetsForPictograph(characterSets, ECharsetEucJp);
   308         SetCharacterSetsForPictograph(characterSets, ECharsetEucJp);
   310         }
   309         }
   311     else
   310     else
   312         {            
   311         {            
   313         CnvUtilities::SCharacterSet characterSet;
   312         CnvUtilities::SCharacterSet characterSet;
   314         characterSet.iConversionData=&CnvJisRoman::ConversionData();
   313         characterSet.iConversionData=&CnvJisRoman::ConversionData();
   315         characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
   314         characterSet.iConvertFromIntermediateBufferInPlace=DummyConvertFromIntermediateBufferInPlace;
   316         characterSet.iEscapeSequence=&KNullDesC8;
   315         characterSet.iEscapeSequence=&KNullDesC8;
   317         ret |= characterSets.Append(characterSet);
   316         characterSets.Append(characterSet);
   318         characterSet.iConversionData=&CnvJisX0208::ConversionData();
   317         characterSet.iConversionData=&CnvJisX0208::ConversionData();
   319         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
   318         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0208ToEucJpPackedInPlace;
   320         characterSet.iEscapeSequence=&KNullDesC8;
   319         characterSet.iEscapeSequence=&KNullDesC8;
   321         ret |= characterSets.Append(characterSet);
   320         characterSets.Append(characterSet);
   322         characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   321         characterSet.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   323         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
   322         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromHalfWidthKatakana8ToEucJpPackedInPlace;
   324         characterSet.iEscapeSequence=&KNullDesC8;
   323         characterSet.iEscapeSequence=&KNullDesC8;
   325         ret |= characterSets.Append(characterSet);
   324         characterSets.Append(characterSet);
   326         characterSet.iConversionData=&CnvJisX0212::ConversionData();
   325         characterSet.iConversionData=&CnvJisX0212::ConversionData();
   327         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
   326         characterSet.iConvertFromIntermediateBufferInPlace=ConvertFromJisX0212ToEucJpPackedInPlace;
   328         characterSet.iEscapeSequence=&KNullDesC8;
   327         characterSet.iEscapeSequence=&KNullDesC8;
   329         ret |= characterSets.Append(characterSet);
   328         characterSets.Append(characterSet);
   330         }
   329         }
   331     __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret));
       
   332     TInt unconvert = CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array());
   330     TInt unconvert = CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, aIndicesOfUnconvertibleCharacters, characterSets.Array());
   333 
   331 
   334     characterSets.Close();
   332     characterSets.Close();
   335     return unconvert;
   333     return unconvert;
   336     }
   334     }
   575         const TDesC8& aForeign,
   573         const TDesC8& aForeign,
   576         TInt& /*aState*/,
   574         TInt& /*aState*/,
   577         TInt& aNumberOfUnconvertibleCharacters,
   575         TInt& aNumberOfUnconvertibleCharacters,
   578         TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
   576         TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter)
   579     {
   577     {
   580     TInt ret =KErrNone;
       
   581     RArray<CnvUtilities::SMethod> methods;
   578     RArray<CnvUtilities::SMethod> methods;
   582     if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
   579     if ( FeatureManager::FeatureSupported(KFeatureIdJapanesePicto) )
   583         {      
   580         {      
   584         CnvUtilities::SMethod method;
   581         CnvUtilities::SMethod method;
   585         SetMethodsForPictograph(methods, ECharsetEucJp);
   582         SetMethodsForPictograph(methods, ECharsetEucJp);
   586         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
   583         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
   587         method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
   584         method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
   588         method.iConversionData=&CnvJisRoman::ConversionData();
   585         method.iConversionData=&CnvJisRoman::ConversionData();
   589         method.iNumberOfBytesPerCharacter=1;
   586         method.iNumberOfBytesPerCharacter=1;
   590         method.iNumberOfCoreBytesPerCharacter=1;
   587         method.iNumberOfCoreBytesPerCharacter=1;
   591         ret |= methods.Append(method);
   588         methods.Append(method);
   592         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
   589         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
   593         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
   590         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
   594         method.iConversionData=&CnvJisX0208::ConversionData();
   591         method.iConversionData=&CnvJisX0208::ConversionData();
   595         method.iNumberOfBytesPerCharacter=2;
   592         method.iNumberOfBytesPerCharacter=2;
   596         method.iNumberOfCoreBytesPerCharacter=2;
   593         method.iNumberOfCoreBytesPerCharacter=2;
   597         ret |= methods.Append(method);
   594         methods.Append(method);
   598         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
   595         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
   599         method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
   596         method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
   600         method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   597         method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   601         method.iNumberOfBytesPerCharacter=2;
   598         method.iNumberOfBytesPerCharacter=2;
   602         method.iNumberOfCoreBytesPerCharacter=1;
   599         method.iNumberOfCoreBytesPerCharacter=1;
   603         ret |= methods.Append(method);
   600         methods.Append(method);
   604         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
   601         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
   605         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
   602         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
   606         method.iConversionData=&CnvJisX0212::ConversionData();
   603         method.iConversionData=&CnvJisX0212::ConversionData();
   607         method.iNumberOfBytesPerCharacter=3;
   604         method.iNumberOfBytesPerCharacter=3;
   608         method.iNumberOfCoreBytesPerCharacter=2;
   605         method.iNumberOfCoreBytesPerCharacter=2;
   609         ret |= methods.Append(method);
   606         methods.Append(method);
   610         }
   607         }
   611     else
   608     else
   612         {
   609         {
   613         CnvUtilities::SMethod method;
   610         CnvUtilities::SMethod method;
   614         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
   611         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisRoman;
   615         method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
   612         method.iConvertToIntermediateBufferInPlace=DummyConvertToIntermediateBufferInPlace;
   616         method.iConversionData=&CnvJisRoman::ConversionData();
   613         method.iConversionData=&CnvJisRoman::ConversionData();
   617         method.iNumberOfBytesPerCharacter=1;
   614         method.iNumberOfBytesPerCharacter=1;
   618         method.iNumberOfCoreBytesPerCharacter=1;
   615         method.iNumberOfCoreBytesPerCharacter=1;
   619         ret |= methods.Append(method);
   616         methods.Append(method);
   620         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
   617         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0208;
   621         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
   618         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0208FromEucJpPackedInPlace;
   622         method.iConversionData=&CnvJisX0208::ConversionData();
   619         method.iConversionData=&CnvJisX0208::ConversionData();
   623         method.iNumberOfBytesPerCharacter=2;
   620         method.iNumberOfBytesPerCharacter=2;
   624         method.iNumberOfCoreBytesPerCharacter=2;
   621         method.iNumberOfCoreBytesPerCharacter=2;
   625         ret |= methods.Append(method);
   622         methods.Append(method);
   626         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
   623         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToHalfWidthKatakana8;
   627         method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
   624         method.iConvertToIntermediateBufferInPlace=ConvertToHalfWidthKatakana8FromEucJpPackedInPlace;
   628         method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   625         method.iConversionData=&CnvHalfWidthKatakana8::ConversionData();
   629         method.iNumberOfBytesPerCharacter=2;
   626         method.iNumberOfBytesPerCharacter=2;
   630         method.iNumberOfCoreBytesPerCharacter=1;
   627         method.iNumberOfCoreBytesPerCharacter=1;
   631         ret |= methods.Append(method);
   628         methods.Append(method);
   632         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
   629         method.iNumberOfBytesAbleToConvert=NumberOfBytesAbleToConvertToJisX0212;
   633         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
   630         method.iConvertToIntermediateBufferInPlace=ConvertToJisX0212FromEucJpPackedInPlace;
   634         method.iConversionData=&CnvJisX0212::ConversionData();
   631         method.iConversionData=&CnvJisX0212::ConversionData();
   635         method.iNumberOfBytesPerCharacter=3;
   632         method.iNumberOfBytesPerCharacter=3;
   636         method.iNumberOfCoreBytesPerCharacter=2;
   633         method.iNumberOfCoreBytesPerCharacter=2;
   637         ret |= methods.Append(method);
   634         methods.Append(method);
   638         }
   635         }
   639     __ASSERT_DEBUG(!ret, User::Panic(_L("RArray append failure"), ret));
       
   640     TInt unconvert = CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter, methods.Array());
   636     TInt unconvert = CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign(aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, aNumberOfUnconvertibleCharacters, aIndexOfFirstByteOfFirstUnconvertibleCharacter, methods.Array());
   641 
   637 
   642     // The following is specific impelementation for brower.
   638     // The following is specific impelementation for brower.
   643     // If brower app calls this API, the yen sign code(0xA5)
   639     // If brower app calls this API, the yen sign code(0xA5)
   644     // must be converted to backslash code(0x5C).
   640     // must be converted to backslash code(0x5C).