os/textandloc/charconvfw/charconvplugins/src/plugins/j5.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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: 
    15 * J5 charconv character converter
    16 *
    17 */
    18 
    19 
    20 #if !defined(__J5_H__)
    21 #define __J5_H__
    22 
    23 /**
    24 J5 charconv character converter which supports automatic conversion for the following
    25 character sets:
    26 	SHIFT-JIS (Windows-31J Microsoft code page 932), 
    27 	ISO-2022-JP-1 (JIS-JP) 
    28 	EUC_JP 
    29 	UTF8 
    30 	UCS2
    31 @internalTechnology 
    32 @released 9.1
    33 */
    34 class CJ5Converter : public CCharacterSetConverterPluginInterface
    35 	{
    36 
    37 public:
    38 	enum TJ5Encoding
    39 		{
    40 		EShiftjis = 1,
    41 		EIso2022jp1, 
    42 		EEucjp, 
    43 		EUtf8, 
    44 		EUcs2,
    45 		EUnknown
    46 		};
    47 
    48 	virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters();
    49 
    50 	virtual TInt ConvertFromUnicode(
    51 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    52 		const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    53 		TDes8& aForeign, 
    54 		const TDesC16& aUnicode, 
    55 		CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters);
    56 
    57 	virtual TInt ConvertToUnicode(
    58 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    59 		TDes16& aUnicode, 
    60 		const TDesC8& aForeign, 
    61 		TInt& aState, 
    62 		TInt& aNumberOfUnconvertibleCharacters, 
    63 		TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    64 
    65 	virtual TBool IsInThisCharacterSetL(
    66 		TBool& aSetToTrue, 
    67 		TInt& aConfidenceLevel, 
    68 		const TDesC8& aSample);
    69 
    70 	static CJ5Converter* NewL();
    71 	virtual ~CJ5Converter();
    72 
    73 private:
    74 	CJ5Converter();
    75 	void ConstructL();
    76 	
    77 	enum TDectectCharacterSet
    78 		{
    79 		EIsCharacterSet = 1,
    80 		EIsNotCharacterSet,
    81 		EMaybeCharacterSet
    82 		};
    83 			
    84 	enum TJ5Encoding DetectEncoding(
    85 		CCnvCharacterSetConverter::TEndianness& aDefaultEndiannessOfForeignCharacters, 
    86 		const TDesC8& aForeign );
    87 
    88 	TBool DetectUcs2( const TDesC8& aForeign,
    89 		CCnvCharacterSetConverter::TEndianness& aTEndianness );
    90 		
    91 	enum TDectectCharacterSet DetectShiftJis( const TDesC8& aForeign,
    92 		TInt &aNumberOfBytesConverted );
    93 	
    94 	enum TDectectCharacterSet DetectUtf8( const TDesC8& aForeign );
    95 
    96 	enum TDectectCharacterSet DetectEucJp( const TDesC8& aForeign,
    97 		TInt &aNumberOfBytesConverted );
    98 
    99 	enum TDectectCharacterSet DetectIso2022( const TDesC8& aForeign );
   100 		
   101 	TInt ConvertEEucjpToUnicode(
   102 		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters,
   103 		TDes16& aUnicode, 
   104 		const TDesC8& aForeign, 
   105 		TInt& aState, 
   106 		TInt& aNumberOfUnconvertibleCharacters, 
   107 		TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
   108 	
   109 	TInt ConvertUcs2ToUnicode(CCnvCharacterSetConverter::TEndianness& aDefaultEndiannessOfForeignCharacters, 
   110 						   TDes16& aUnicode,		
   111 						   const TDesC8& aForeign,	
   112 						   TInt& aNumberOfUnconvertibleCharacters,   
   113 						   TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter); 
   114 									  
   115 	};
   116 
   117 	
   118 							  
   119 // EucJp conversion methods	
   120 void DummyConvertToIntermediateBufferInPlace(TDes8&);
   121 void ConvertToJisX0212FromEucJpPackedInPlace(TDes8& aDescriptor);
   122 void ConvertToJisX0208FromEucJpPackedInPlace(TDes8& aDescriptor);
   123 void ConvertToHalfWidthKatakana8FromEucJpPackedInPlace(TDes8& aDescriptor);
   124 TInt NumberOfBytesAbleToConvertToJisRoman(const TDesC8& aDescriptor);
   125 TInt NumberOfBytesAbleToConvertToJisX0208(const TDesC8& aDescriptor);
   126 TInt NumberOfBytesAbleToConvertToHalfWidthKatakana8(const TDesC8& aDescriptor);
   127 TInt NumberOfBytesAbleToConvertToJisX0212(const TDesC8& aDescriptor);
   128 
   129 #endif
   130