os/textandloc/charconvfw/charconv_fw/inc/utf.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/charconvfw/charconv_fw/inc/utf.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#if !defined(__UTF_H__)
    1.23 +#define __UTF_H__
    1.24 +
    1.25 +#if !defined(__E32STD_H__)
    1.26 +#include <e32std.h>
    1.27 +#endif
    1.28 +
    1.29 +
    1.30 +class CnvUtfConverter
    1.31 +/** 
    1.32 +Converts text between Unicode (UCS-2) and the two Unicode transformation 
    1.33 +formats UTF-7 and UTF-8. There are no functions to convert directly between 
    1.34 +UTF-7 and UTF-8.
    1.35 +
    1.36 +Objects of this class do not need to be created because all the member functions 
    1.37 +are static. The four functions are passed text in the second argument and 
    1.38 +output the resulting text in the first argument. Sixteen-bit descriptors are 
    1.39 +used to hold text encoded in UCS-2 (i.e. normal 16 bit Unicode), and eight-bit 
    1.40 +descriptors are used to hold text encoded in either of the transformation 
    1.41 +formats.
    1.42 +
    1.43 +The conversion functions return the number of characters which were not converted 
    1.44 +because the output descriptor was not long enough to hold all of the converted 
    1.45 +text. This allows users of this class to perform partial conversions on an 
    1.46 +input descriptor, handling the case when the input descriptor is truncated 
    1.47 +mid way through a multi-byte character. The caller does not have to guess 
    1.48 +how big to make the output descriptor for a given input descriptor- they 
    1.49 +can simply do the conversion in a loop using a small output descriptor. The 
    1.50 +ability to handle truncated descriptors is particularly useful if the caller 
    1.51 +is receiving information in chunks from an external source. 
    1.52 +@publishedAll
    1.53 +@released
    1.54 +*/
    1.55 +	{
    1.56 +public:
    1.57 +	/** Conversion error flags. At this stage there is only one error flag 
    1.58 +	- others may be added in the future. */
    1.59 +	enum TError
    1.60 +		{
    1.61 + 		/** The input descriptor contains a single corrupt character. This 
    1.62 + 		might occur when the input descriptor only contains some of the bytes 
    1.63 + 		of a single multi-byte character. */
    1.64 +		EErrorIllFormedInput=KErrCorrupt
    1.65 +		};
    1.66 +	 
    1.67 +	 /** Initial value for the state argument in a set of related calls to
    1.68 +	ConvertToUnicode(). */
    1.69 +	enum {KStateDefault=0}; 
    1.70 +public:
    1.71 +	// the conversion functions return either one of the TError values above, or the number of unconverted elements left at the end of the input descriptor
    1.72 +	IMPORT_C static TInt ConvertFromUnicodeToUtf7(TDes8& aUtf7, const TDesC16& aUnicode, TBool aEncodeOptionalDirectCharactersInBase64);
    1.73 +	static TInt ConvertFromUnicodeToUtf7(TDes8& aUtf7, const TDesC16& aUnicode, TBool aIsImapUtf7, TBool aEncodeOptionalDirectCharactersInBase64);
    1.74 +	IMPORT_C static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode);
    1.75 +	static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode, TBool aGenerateJavaConformantUtf8);
    1.76 +	IMPORT_C static TInt ConvertToUnicodeFromUtf7(TDes16& aUnicode, const TDesC8& aUtf7, TInt& aState);
    1.77 +	static TInt ConvertToUnicodeFromUtf7(TDes16& aUnicode, const TDesC8& aUtf7, TBool aIsImapUtf7, TInt& aState);
    1.78 +	IMPORT_C static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8);
    1.79 +	static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8, TBool aGenerateJavaConformantUtf8);
    1.80 +	static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8, TBool aGenerateJavaConformantUtf8,
    1.81 +			TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    1.82 +
    1.83 +	IMPORT_C static HBufC8* ConvertFromUnicodeToUtf7L(const TDesC16& aUnicode,TBool aEncodeOptionalDirectCharactersInBase64);
    1.84 +	IMPORT_C static HBufC8* ConvertFromUnicodeToUtf8L(const TDesC16& aUnicode);
    1.85 +	IMPORT_C static HBufC16* ConvertToUnicodeFromUtf7L(const TDesC8& aUtf7); 
    1.86 +	IMPORT_C static HBufC16* ConvertToUnicodeFromUtf8L(const TDesC8& aUtf8);
    1.87 +
    1.88 +
    1.89 +	};
    1.90 +
    1.91 +#endif
    1.92 +