epoc32/include/vutil.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/vutil.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/vutil.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,189 @@
     1.4 -vutil.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 +#ifndef __VUTIL_H__
    1.21 +#define __VUTIL_H__
    1.22 +
    1.23 +// System includes
    1.24 +#ifndef __E32BASE_H__
    1.25 +#include <e32base.h>
    1.26 +#endif
    1.27 +#ifndef __F32FILE_H__
    1.28 +#include <f32file.h>
    1.29 +#endif
    1.30 +#ifndef __CHARCONV_H__
    1.31 +#include <charconv.h>
    1.32 +#endif
    1.33 +
    1.34 +
    1.35 +class Versit
    1.36 +/** Provides Versit-specific encoding and character set identifiers. 
    1.37 +@publishedAll
    1.38 +@released
    1.39 +*/
    1.40 +	{
    1.41 +public:
    1.42 +	/** Versit-specific encoding identifiers. 
    1.43 +	@publishedAll
    1.44 +	@released
    1.45 +	*/
    1.46 +	enum TVersitEncoding
    1.47 +		{
    1.48 +		/** No encoding. */
    1.49 +		ENoEncoding,
    1.50 +		/** Quoted Printable encoding. */
    1.51 +		EQuotedPrintableEncoding,
    1.52 +		/** Base 64 encoding. */
    1.53 +		EBase64Encoding,
    1.54 +
    1.55 +		// Used internally - not to be used by versit clients
    1.56 +		/** Eight bit encoding. */
    1.57 +		EEightBitEncoding
    1.58 +		};
    1.59 +
    1.60 +	/** Versit-specific character set identifiers. These are used in the Versit API 
    1.61 +	to represent foreign (non-Unicode) character sets for vCard and vCalendar 
    1.62 +	properties. 
    1.63 +	@publishedAll
    1.64 +	@released */
    1.65 +	enum TVersitCharSet
    1.66 +		{
    1.67 +		/** Unknown character set. */
    1.68 +		EUnknownCharSet,
    1.69 +		/** ASCII (7-bit).*/
    1.70 +		EUSAsciiCharSet,	
    1.71 +		/** UTF-8 Unicode transformation format. */
    1.72 +		EUTF8CharSet,
    1.73 +		/** UTF-7 Unicode transformation format. */
    1.74 +		EUTF7CharSet,
    1.75 +		/** ISO 8859-1 (8-bit). */
    1.76 +		EISO88591CharSet,
    1.77 +		/** ISO 8859-2 (8-bit). */
    1.78 +		EISO88592CharSet,
    1.79 +		/** ISO 8859-4 (8-bit). */
    1.80 +		EISO88594CharSet,
    1.81 +		/** ISO 8859-5 (8-bit). */
    1.82 +		EISO88595CharSet,
    1.83 +		/** ISO 8859-7 (8-bit). */
    1.84 +		EISO88597CharSet,
    1.85 +		/** ISO 8859-9 (8-bit). */
    1.86 +		EISO88599CharSet,
    1.87 +		/** ISO 8859-3 (8-bit). */
    1.88 +		EISO88593CharSet,
    1.89 +		/** ISO 8859-10 (8-bit). */
    1.90 +		EISO885910CharSet,
    1.91 +		/** GB 2312. */
    1.92 +		EGB231280CharSet,
    1.93 +		/** GBK. */
    1.94 +		EGBKCharSet,
    1.95 +		/** Big 5. */
    1.96 +		EBIG5CharSet,
    1.97 +		/** ISO-2022-JP. */
    1.98 +		EISO2022JPCharSet,
    1.99 +		/** EUC-JP. */
   1.100 +		EEUCJPCharSet,
   1.101 +		/** Shift JIS. */
   1.102 +		EShiftJISCharSet,
   1.103 +		/** JIS. */
   1.104 +		EJISCharSet,
   1.105 +		/** Must be first character set. */
   1.106 +		EFirstCharSet=EUSAsciiCharSet,
   1.107 +		/** Must be last character set. */
   1.108 +		ELastCharSet=EJISCharSet
   1.109 +		};
   1.110 +
   1.111 +	class TEncodingAndCharset
   1.112 +	/** Specifies an encoding, a character set and a character set converter. 
   1.113 +	@publishedAll
   1.114 +	@released */
   1.115 +		{
   1.116 +	public:
   1.117 +		inline TEncodingAndCharset(TVersitEncoding aEncoding,TUint aCharSetId) :iEncoding(aEncoding), iCharSetId(aCharSetId) 
   1.118 +		/** The C++ constructor initialises the encoding and character set.
   1.119 +	
   1.120 +		@param aEncoding An encoding.
   1.121 +		@param aCharSetId A character set. */
   1.122 +			{}
   1.123 +	public:
   1.124 +		/** An encoding. */
   1.125 +		TVersitEncoding iEncoding;
   1.126 +		/** A character set. */
   1.127 +		TUint iCharSetId;
   1.128 +		/** A character set converter. */
   1.129 +		CCnvCharacterSetConverter* iConverter;
   1.130 +		};
   1.131 +	};
   1.132 +
   1.133 +class CVersitUnicodeUtils : public CBase
   1.134 +/** Versit Unicode utilities class. 
   1.135 +
   1.136 +This enables conversion between Unicode and ISO character sets. 
   1.137 +@publishedAll
   1.138 +@released
   1.139 +*/
   1.140 +	{
   1.141 +public:
   1.142 +	IMPORT_C ~CVersitUnicodeUtils();
   1.143 +	IMPORT_C HBufC8* NarrowL(const TDesC& aDesC);
   1.144 +	IMPORT_C HBufC8* NarrowLC(const TDesC& aDesC);
   1.145 +	IMPORT_C HBufC* WidenL(const TDesC8& aDesC8);
   1.146 +	IMPORT_C HBufC* WidenLC(const TDesC8& aDesC8);
   1.147 +	IMPORT_C void CreateConverterL();
   1.148 +	CCnvCharacterSetConverter::TAvailability SetCurrentCharSetL(TUint aCharacterSet);
   1.149 +
   1.150 +public:
   1.151 +	inline CCnvCharacterSetConverter& CharacterSetConverter() const;
   1.152 +	inline TUint ConvertStandardNameL(const TDesC8& aStandardNameOfCharacterSet);
   1.153 +	inline HBufC8* StandardNameL(TUint aCharSetId);
   1.154 +	TUint AutoDetectCharSetL(const TDesC8& aSample,const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aAutoDetectCharSets);
   1.155 +
   1.156 +private:
   1.157 +	RFs iFsSession;
   1.158 +	CCnvCharacterSetConverter* iUnicodeConverter;
   1.159 +	TBool iFsConnected;
   1.160 +	TUint iCurrentConverterCharSet;
   1.161 +	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharSetsAvailable;
   1.162 +	};
   1.163 +
   1.164 +
   1.165 +inline CCnvCharacterSetConverter& CVersitUnicodeUtils::CharacterSetConverter() const
   1.166 +/** Returns the character set converter created in CreateConverterL().
   1.167 +	
   1.168 +@return A character set converter. */
   1.169 +	{
   1.170 +	return *iUnicodeConverter;
   1.171 +	}
   1.172 +inline TUint CVersitUnicodeUtils::ConvertStandardNameL(const TDesC8& aStandardNameOfCharacterSet)
   1.173 +/** Returns the Symbian OS UID for a character set from its Internet-standard 
   1.174 +name.
   1.175 +	
   1.176 +@param aStandardNameOfCharacterSet Internet-standard name of a character set 
   1.177 +encoded in 8-bit ASCII.
   1.178 +@return The Symbian OS UID of the specified character set. If the name is not 
   1.179 +known, zero is returned. */
   1.180 +	{
   1.181 +	return iUnicodeConverter->ConvertStandardNameOfCharacterSetToIdentifierL(aStandardNameOfCharacterSet,iFsSession);
   1.182 +	}
   1.183 +inline HBufC8* CVersitUnicodeUtils::StandardNameL(TUint aCharSetId)
   1.184 +/** Returns the Internet-standard name of a character set, from its Symbian OS UID. 
   1.185 +
   1.186 +@param aCharSetId The Symbian OS UID of a character set.
   1.187 +@return The Internet-standard name or MIME name of the specified character 
   1.188 +set, or NULL if the UID is not known. The name is encoded in 8-bit ASCII. */
   1.189 +	{
   1.190 +	return iUnicodeConverter->ConvertCharacterSetIdentifierToStandardNameL(aCharSetId,iFsSession);
   1.191 +	}
   1.192 +
   1.193 +#endif