1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
26 #ifndef __CHARCONV_H__
32 /** Provides Versit-specific encoding and character set identifiers.
38 /** Versit-specific encoding identifiers.
46 /** Quoted Printable encoding. */
47 EQuotedPrintableEncoding,
48 /** Base 64 encoding. */
51 // Used internally - not to be used by versit clients
52 /** Eight bit encoding. */
56 /** Versit-specific character set identifiers. These are used in the Versit API
57 to represent foreign (non-Unicode) character sets for vCard and vCalendar
63 /** Unknown character set. */
67 /** UTF-8 Unicode transformation format. */
69 /** UTF-7 Unicode transformation format. */
71 /** ISO 8859-1 (8-bit). */
73 /** ISO 8859-2 (8-bit). */
75 /** ISO 8859-4 (8-bit). */
77 /** ISO 8859-5 (8-bit). */
79 /** ISO 8859-7 (8-bit). */
81 /** ISO 8859-9 (8-bit). */
83 /** ISO 8859-3 (8-bit). */
85 /** ISO 8859-10 (8-bit). */
101 /** Must be first character set. */
102 EFirstCharSet=EUSAsciiCharSet,
103 /** Must be last character set. */
104 ELastCharSet=EJISCharSet
107 class TEncodingAndCharset
108 /** Specifies an encoding, a character set and a character set converter.
113 inline TEncodingAndCharset(TVersitEncoding aEncoding,TUint aCharSetId) :iEncoding(aEncoding), iCharSetId(aCharSetId)
114 /** The C++ constructor initialises the encoding and character set.
116 @param aEncoding An encoding.
117 @param aCharSetId A character set. */
121 TVersitEncoding iEncoding;
122 /** A character set. */
124 /** A character set converter. */
125 CCnvCharacterSetConverter* iConverter;
129 class CVersitUnicodeUtils : public CBase
130 /** Versit Unicode utilities class.
132 This enables conversion between Unicode and ISO character sets.
138 IMPORT_C ~CVersitUnicodeUtils();
139 IMPORT_C HBufC8* NarrowL(const TDesC& aDesC);
140 IMPORT_C HBufC8* NarrowLC(const TDesC& aDesC);
141 IMPORT_C HBufC* WidenL(const TDesC8& aDesC8);
142 IMPORT_C HBufC* WidenLC(const TDesC8& aDesC8);
143 IMPORT_C void CreateConverterL();
144 CCnvCharacterSetConverter::TAvailability SetCurrentCharSetL(TUint aCharacterSet);
147 inline CCnvCharacterSetConverter& CharacterSetConverter() const;
148 inline TUint ConvertStandardNameL(const TDesC8& aStandardNameOfCharacterSet);
149 inline HBufC8* StandardNameL(TUint aCharSetId);
150 TUint AutoDetectCharSetL(const TDesC8& aSample,const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aAutoDetectCharSets);
154 CCnvCharacterSetConverter* iUnicodeConverter;
156 TUint iCurrentConverterCharSet;
157 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharSetsAvailable;
161 inline CCnvCharacterSetConverter& CVersitUnicodeUtils::CharacterSetConverter() const
162 /** Returns the character set converter created in CreateConverterL().
164 @return A character set converter. */
166 return *iUnicodeConverter;
168 inline TUint CVersitUnicodeUtils::ConvertStandardNameL(const TDesC8& aStandardNameOfCharacterSet)
169 /** Returns the Symbian OS UID for a character set from its Internet-standard
172 @param aStandardNameOfCharacterSet Internet-standard name of a character set
173 encoded in 8-bit ASCII.
174 @return The Symbian OS UID of the specified character set. If the name is not
175 known, zero is returned. */
177 return iUnicodeConverter->ConvertStandardNameOfCharacterSetToIdentifierL(aStandardNameOfCharacterSet,iFsSession);
179 inline HBufC8* CVersitUnicodeUtils::StandardNameL(TUint aCharSetId)
180 /** Returns the Internet-standard name of a character set, from its Symbian OS UID.
182 @param aCharSetId The Symbian OS UID of a character set.
183 @return The Internet-standard name or MIME name of the specified character
184 set, or NULL if the UID is not known. The name is encoded in 8-bit ASCII. */
186 return iUnicodeConverter->ConvertCharacterSetIdentifierToStandardNameL(aCharSetId,iFsSession);