epoc32/include/utf.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/utf.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/utf.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,85 @@
     1.4 -utf.h
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.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 +#if !defined(__UTF_H__)
    1.21 +#define __UTF_H__
    1.22 +
    1.23 +#if !defined(__E32STD_H__)
    1.24 +#include <e32std.h>
    1.25 +#endif
    1.26 +
    1.27 +
    1.28 +class CnvUtfConverter
    1.29 +/** 
    1.30 +Converts text between Unicode (UCS-2) and the two Unicode transformation 
    1.31 +formats UTF-7 and UTF-8. There are no functions to convert directly between 
    1.32 +UTF-7 and UTF-8.
    1.33 +
    1.34 +Objects of this class do not need to be created because all the member functions 
    1.35 +are static. The four functions are passed text in the second argument and 
    1.36 +output the resulting text in the first argument. Sixteen-bit descriptors are 
    1.37 +used to hold text encoded in UCS-2 (i.e. normal 16 bit Unicode), and eight-bit 
    1.38 +descriptors are used to hold text encoded in either of the transformation 
    1.39 +formats.
    1.40 +
    1.41 +The conversion functions return the number of characters which were not converted 
    1.42 +because the output descriptor was not long enough to hold all of the converted 
    1.43 +text. This allows users of this class to perform partial conversions on an 
    1.44 +input descriptor, handling the case when the input descriptor is truncated 
    1.45 +mid way through a multi-byte character. The caller does not have to guess 
    1.46 +how big to make the output descriptor for a given input descriptor- they 
    1.47 +can simply do the conversion in a loop using a small output descriptor. The 
    1.48 +ability to handle truncated descriptors is particularly useful if the caller 
    1.49 +is receiving information in chunks from an external source. 
    1.50 +@publishedAll
    1.51 +@released
    1.52 +*/
    1.53 +	{
    1.54 +public:
    1.55 +	/** Conversion error flags. At this stage there is only one error flag 
    1.56 +	- others may be added in the future. */
    1.57 +	enum TError
    1.58 +		{
    1.59 + 		/** The input descriptor contains a single corrupt character. This 
    1.60 + 		might occur when the input descriptor only contains some of the bytes 
    1.61 + 		of a single multi-byte character. */
    1.62 +		EErrorIllFormedInput=KErrCorrupt
    1.63 +		};
    1.64 +	 
    1.65 +	 /** Initial value for the state argument in a set of related calls to
    1.66 +	ConvertToUnicode(). */
    1.67 +	enum {KStateDefault=0}; 
    1.68 +public:
    1.69 +	// 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.70 +	IMPORT_C static TInt ConvertFromUnicodeToUtf7(TDes8& aUtf7, const TDesC16& aUnicode, TBool aEncodeOptionalDirectCharactersInBase64);
    1.71 +	static TInt ConvertFromUnicodeToUtf7(TDes8& aUtf7, const TDesC16& aUnicode, TBool aIsImapUtf7, TBool aEncodeOptionalDirectCharactersInBase64);
    1.72 +	IMPORT_C static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode);
    1.73 +	static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode, TBool aGenerateJavaConformantUtf8);
    1.74 +	IMPORT_C static TInt ConvertToUnicodeFromUtf7(TDes16& aUnicode, const TDesC8& aUtf7, TInt& aState);
    1.75 +	static TInt ConvertToUnicodeFromUtf7(TDes16& aUnicode, const TDesC8& aUtf7, TBool aIsImapUtf7, TInt& aState);
    1.76 +	IMPORT_C static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8);
    1.77 +	static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8, TBool aGenerateJavaConformantUtf8);
    1.78 +	static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8, TBool aGenerateJavaConformantUtf8,
    1.79 +			TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter);
    1.80 +
    1.81 +	IMPORT_C static HBufC8* ConvertFromUnicodeToUtf7L(const TDesC16& aUnicode,TBool aEncodeOptionalDirectCharactersInBase64);
    1.82 +	IMPORT_C static HBufC8* ConvertFromUnicodeToUtf8L(const TDesC16& aUnicode);
    1.83 +	IMPORT_C static HBufC16* ConvertToUnicodeFromUtf7L(const TDesC8& aUtf7); 
    1.84 +	IMPORT_C static HBufC16* ConvertToUnicodeFromUtf8L(const TDesC8& aUtf8);
    1.85 +
    1.86 +
    1.87 +	};
    1.88 +
    1.89 +#endif