epoc32/include/charactersetconverter.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description: 
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@2
    18
williamr@2
    19
#if !defined(__CHARACTERSETCONVERTER_H__)
williamr@2
    20
#define __CHARACTERSETCONVERTER_H__
williamr@2
    21
williamr@2
    22
#include <e32base.h>
williamr@2
    23
#include <ecom/ecom.h>
williamr@2
    24
williamr@2
    25
/**
williamr@2
    26
This constant holds the UID of the CharConv Character Set Conversion 
williamr@2
    27
ECOM Interface.
williamr@2
    28
@publishedAll
williamr@2
    29
@released
williamr@2
    30
*/
williamr@2
    31
const TUid KCharacterSetConvertorInterfaceUid = {0x101F7F1D};
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
This is the base class defining the methods in the CharConv Character Set
williamr@2
    35
Conversion plugin interface. CharConv plugin suppliers would define 
williamr@2
    36
implementation classes inheriting from this interface class to add additional
williamr@2
    37
character set support to CharConv.
williamr@2
    38
@publishedAll
williamr@2
    39
@released
williamr@2
    40
*/
williamr@2
    41
NONSHARABLE_CLASS(CCharacterSetConverterPluginInterface) : public CBase
williamr@2
    42
	{
williamr@2
    43
williamr@2
    44
public:
williamr@2
    45
williamr@2
    46
/**
williamr@2
    47
 *
williamr@2
    48
 * A function prototype which must be implemented by a character
williamr@2
    49
 * conversion plug-in DLL to return the character (represented by one or
williamr@2
    50
 * more byte values) which is used by default as the replacement for
williamr@2
    51
 * unconvertible Unicode characters.
williamr@2
    52
 *
williamr@2
    53
 * This character is used when converting from Unicode into a foreign
williamr@2
    54
 * character set, if there is no equivalent for the Unicode character in
williamr@2
    55
 * the foreign character set. The default replacement character can be
williamr@2
    56
 * overriden by a call to <code>CCnvCharacterSetConverter::SetReplacemen-
williamr@2
    57
 * tForUnconvertibleUnicodeCharactersL()</code>.This function is exported
williamr@2
    58
 * at ordinal position 1 in the plug-in DLL. It is called by <code>CCnvC-
williamr@2
    59
 * haracterSetConverter::PrepareToConvertToOrFromL()</code>.To implement
williamr@2
    60
 * this function, you should #include convgeneratedcpp.h in the cpp file.
williamr@2
    61
 * This gives access to the
williamr@2
    62
 * <code>ReplacementForUnconvertibleUnicodeCharacters_internal()</code>
williamr@2
    63
 * function. This function can then be implemented by calling
williamr@2
    64
 * <code>ReplacementForUnconvertibleUnicodeCharacters_internal()</code>.
williamr@2
    65
 *
williamr@2
    66
 * @since     6.0
williamr@2
    67
 * @return   " const TDesC8& "
williamr@2
    68
 *            The single character which is to be used to replace
williamr@2
    69
 *            unconvertible characters.
williamr@2
    70
 */
williamr@2
    71
	virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters() = 0;
williamr@2
    72
williamr@2
    73
/**
williamr@2
    74
 *
williamr@2
    75
 * A function prototype which must be implemented by a character
williamr@2
    76
 * conversion plug-in DLL to convert from Unicode into a foreign
williamr@2
    77
 * character set.
williamr@2
    78
 *
williamr@2
    79
 * This function is exported at ordinal position 2 in the plug-in DLL. It
williamr@2
    80
 * is called by
williamr@2
    81
 * <code>CCnvCharacterSetConverter::ConvertFromUnicode()</code>.For many
williamr@2
    82
 * non-complex character sets, the implementation of this function is
williamr@2
    83
 * trivial. Include convgeneratedcpp.h in the .cpp file to get access to
williamr@2
    84
 * the <code>SCnvConversionData</code> object called
williamr@2
    85
 * <code>conversionData</code>. Then call
williamr@2
    86
 * <code>CCnvCharacterSetConverter::DoConvertFromUnicode()</code>
williamr@2
    87
 * specifying <code>conversionData</code> as the first argument and
williamr@2
    88
 * passing in all parameters unchanged.For complex character sets, you
williamr@2
    89
 * need to create an array of character conversion data objects
williamr@2
    90
 * (<code>CnvUtilities::SCharacterSet</code>s), then call
williamr@2
    91
 * <code>CnvUtilities::ConvertFromUnicode()</code>.
williamr@2
    92
 *
williamr@2
    93
 * @since     6.0
williamr@2
    94
 * @param     " CCnvCharacterSetConverter::TEndianness
williamr@2
    95
		  aDefaultEndiannessOfForeignCharacters "
williamr@2
    96
 *            The default endian-ness to use when writing the
williamr@2
    97
 *            characters in the foreign character set.
williamr@2
    98
 * @param     " const TDesC8& aReplacementForUnconvertibleUnicodeCharacters
williamr@2
    99
		  "
williamr@2
   100
 *            The single character which is used to replace
williamr@2
   101
 *            unconvertible characters.
williamr@2
   102
 * @param     " TDes8& aForeign "
williamr@2
   103
 *            On return, contains the converted text in the target
williamr@2
   104
 *            non-Unicode character set.
williamr@2
   105
 * @param     " const TDesC16& aUnicode "
williamr@2
   106
 *            The source Unicode text to be converted.
williamr@2
   107
 * @param     " CCnvCharacterSetConverter::TArrayOfAscendingIndices&
williamr@2
   108
		  aIndicesOfUnconvertibleCharacters "
williamr@2
   109
 *            A buffer which on return holds the indices of each
williamr@2
   110
 *            Unicode character in the source text which could not
williamr@2
   111
 *            be converted (because the target character set does
williamr@2
   112
 *            not have an equivalent character).
williamr@2
   113
 * @return   " TInt "
williamr@2
   114
 *            The number of unconverted characters left at the end
williamr@2
   115
 *            of the input descriptor (e.g. because
williamr@2
   116
 *            <code>aForeign</code> was not long enough to hold all
williamr@2
   117
 *            the text), or a negative error value, as defined in
williamr@2
   118
 *            <code>TError</code>.
williamr@2
   119
 */
williamr@2
   120
	virtual TInt ConvertFromUnicode(
williamr@2
   121
		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
williamr@2
   122
		const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
williamr@2
   123
		TDes8& aForeign, 
williamr@2
   124
		const TDesC16& aUnicode, 
williamr@2
   125
		CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters) = 0;
williamr@2
   126
williamr@2
   127
/**
williamr@2
   128
 *
williamr@2
   129
 * A function prototype which must be implemented by a character
williamr@2
   130
 * conversion plug-in DLL to convert from a foreign character set into
williamr@2
   131
 * Unicode.
williamr@2
   132
 *
williamr@2
   133
 * This function is exported at ordinal position 3 in the plug-in DLL. It
williamr@2
   134
 * is called by
williamr@2
   135
 * <code>CCnvCharacterSetConverter::ConvertToUnicode()</code>.For many
williamr@2
   136
 * non-complex character sets, the implementation of this function is
williamr@2
   137
 * trivial. Include convgeneratedcpp.h in the .cpp file to get access to
williamr@2
   138
 * the <code>SCnvConversionData</code> object called
williamr@2
   139
 * <code>conversionData</code>. Then call
williamr@2
   140
 * <code>CCnvCharacterSetConverter::DoConvertToUnicode()</code>
williamr@2
   141
 * specifying <code>conversionData</code> as the first argument and
williamr@2
   142
 * passing in all other parameters unchanged.For complex character sets,
williamr@2
   143
 * you need to create an array of character conversion methods
williamr@2
   144
 * (<code>CnvUtilities::SMethod</code>s or
williamr@2
   145
 * <code>CnvUtilities::SState</code>s, depending on whether the complex
williamr@2
   146
 * character set encoding is modal or not), then call
williamr@2
   147
 * <code>CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign()</code>
williamr@2
   148
 * or <code>CnvUtilities::ConvertToUnicodeFromModalForeign()</code>.
williamr@2
   149
 *
williamr@2
   150
 * @since     6.0
williamr@2
   151
 * @param     " CCnvCharacterSetConverter::TEndianness
williamr@2
   152
		  aDefaultEndiannessOfForeignCharacters "
williamr@2
   153
 *            The default endian-ness to use when reading characters
williamr@2
   154
 *            in the foreign character set.
williamr@2
   155
 * @param     " TDes16& aUnicode "
williamr@2
   156
 *            On return, contains the text converted into Unicode.
williamr@2
   157
 * @param     " const TDesC8& aForeign "
williamr@2
   158
 *            The non-Unicode source text to be converted.
williamr@2
   159
 * @param     " TInt& aState "
williamr@2
   160
 *            Used to save state information across multiple calls
williamr@2
   161
 *            to <code>ConvertToUnicode()</code>.
williamr@2
   162
 * @param     " TInt& aNumberOfUnconvertibleCharacters "
williamr@2
   163
 *            On return, contains the number of bytes which were not
williamr@2
   164
 *            converted.
williamr@2
   165
 * @param     " TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter "
williamr@2
   166
 *            On return, contains the index of the first bytein the
williamr@2
   167
 *            input text that could not be converted. A negative
williamr@2
   168
 *            value indicates that all the characters were
williamr@2
   169
 *            converted.
williamr@2
   170
 * @return   " TInt "
williamr@2
   171
 *            The number of unconverted bytes left at the end of the
williamr@2
   172
 *            input descriptor (e.g. because the output descriptor
williamr@2
   173
 *            is not long enough to hold all the text), or one of
williamr@2
   174
 *            the error values defined in <code>TError</code>.
williamr@2
   175
 */
williamr@2
   176
	virtual TInt ConvertToUnicode(
williamr@2
   177
		CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
williamr@2
   178
		TDes16& aUnicode, 
williamr@2
   179
		const TDesC8& aForeign, 
williamr@2
   180
		TInt& aState, 
williamr@2
   181
		TInt& aNumberOfUnconvertibleCharacters, 
williamr@2
   182
		TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter) = 0;
williamr@2
   183
williamr@2
   184
/**
williamr@2
   185
 *
williamr@2
   186
 * A function which must be implemented by a character conversion plug-in
williamr@2
   187
 * DLL to calculate how probable it is that a sample piece of text is
williamr@2
   188
 * encoded in this character set.
williamr@2
   189
 *
williamr@2
   190
 * This function was added in 6.1 as the 4th-ordinal exported function in
williamr@2
   191
 * the plug-in DLL interface. It is called by
williamr@2
   192
 * <code>CCnvCharacterSetConverter::AutoDetectCharacterSetL()</code> for
williamr@2
   193
 * each character conversion plug-in DLL.
williamr@2
   194
 *
williamr@2
   195
 * @since     6.1
williamr@2
   196
 * @param     "  TBool& aSetToTrue"
williamr@2
   197
 *            This value should be set to <code>ETrue</code>. It is
williamr@2
   198
 *            used to indicate to <code>CCnvCharacterSetConverter::-
williamr@2
   199
 *            AutoDetectCharacterSetL()</code> that the plug-in DLL
williamr@2
   200
 *            is implementing a function of this signature and is
williamr@2
   201
 *            therefore not the empty, reserved function that was
williamr@2
   202
 *            previously exported at the 4th ordinal position in the
williamr@2
   203
 *            plug-in DLL in v6.0.
williamr@2
   204
 * @param     "TInt& aConfidenceLevel"
williamr@2
   205
 *            On return, indicates how confident the function is
williamr@2
   206
 *            about its return value. Set to a value between 0 and
williamr@2
   207
 *            100. Zero indicates no confidence, (and the return
williamr@2
   208
 *            value should be disregarded), 100 indicates total
williamr@2
   209
 *            confidence.
williamr@2
   210
 * @param     "const TDesC8& aSample"
williamr@2
   211
 *            The sample text string, as passed to <code>CCnvCharac-
williamr@2
   212
 *            terSetConverter::AutoDetectCharacterSetL()</code>.
williamr@2
   213
 * @return   "TBool"
williamr@2
   214
 *            <code>ETrue</code> if it is more probable that the
williamr@2
   215
 *            sample text is encoded in this character set than not.
williamr@2
   216
 *            <code>EFalse</code> if it is more probable that the
williamr@2
   217
 *            sample text is not encoded in this character set. The
williamr@2
   218
 *            confidence level applies to this value.
williamr@2
   219
 */
williamr@2
   220
	virtual TBool IsInThisCharacterSetL(
williamr@2
   221
		TBool& aSetToTrue, 
williamr@2
   222
		TInt& aConfidenceLevel, 
williamr@2
   223
		const TDesC8& aSample) = 0;
williamr@2
   224
williamr@2
   225
	static CCharacterSetConverterPluginInterface* NewL(TUid aInterfaceImplUid)
williamr@2
   226
		{
williamr@2
   227
		return reinterpret_cast <CCharacterSetConverterPluginInterface*> (
williamr@2
   228
			REComSession::CreateImplementationL(
williamr@2
   229
			aInterfaceImplUid,
williamr@2
   230
			_FOFF(CCharacterSetConverterPluginInterface, iDtor_ID_Key))); 
williamr@2
   231
		};
williamr@2
   232
	
williamr@2
   233
/**
williamr@2
   234
Destroys the Charconv Plug-in interface implementation specified by iDtor_ID_Key
williamr@2
   235
*/
williamr@2
   236
	virtual ~CCharacterSetConverterPluginInterface()
williamr@2
   237
		{
williamr@2
   238
		REComSession::DestroyedImplementation(iDtor_ID_Key);
williamr@2
   239
		};
williamr@2
   240
	
williamr@2
   241
williamr@2
   242
private:
williamr@2
   243
williamr@2
   244
	TUid iDtor_ID_Key;
williamr@2
   245
williamr@2
   246
	};
williamr@2
   247
williamr@2
   248
williamr@2
   249
#endif //__CHARACTERSETCONVERTER_H__
williamr@4
   250