class CCnvCharacterSetConverter : public CBase |
Converts text between Unicode and other character sets.
The first stage of the conversion is to specify the non-Unicode character set being converted to or from. This is done by calling one of the overloads of PrepareToConvertToOrFromL().
The second stage is to convert the text, using one of the overloads of ConvertFromUnicode() or ConvertToUnicode().
Where possible the first documented overload of PrepareToConvertToOrFromL() should be used because the second overload panics if the specified character set is not available: the first overload simply returns whether the character set is available or not available. However if the conversions are to be performed often, or if the user must select the character set for the conversion from a list, the second overload may be more appropriate.
The first overload is less efficient than the second, because it searches through the file system for the selected character set every time it is invoked. The second overload searches through an array of all available character sets. In this method, the file system need only be searched once - when CreateArrayOfCharacterSetsAvailableLC() or CreateArrayOfCharacterSetsAvailableL() is used to create the array.
The conversion functions allow users of this class to perform partial conversions on an input descriptor, handling the situation where the input descriptor is truncated mid way through a multi-byte character. This means that you do not have to guess how big to make the output descriptor for a given input descriptor, you can simply do the conversion in a loop using a small output descriptor. The ability to handle truncated descriptors also allows users of the class to convert information received in chunks from an external source.
The class also provides a number of utility functions.
Private Member Functions | |
---|---|
CCnvCharacterSetConverter() | |
TCharacterSetSearch | AppendHardCodedCharacterSetIfRequiredL(CArrayFix< SCharacterSet > &, TUint, TUint, const TDesC &) |
void | ConstructL() |
void | DeleteConversionData(const SCnvConversionData *) |
void | DeleteConversionData(TAny *) |
CArrayFix< SCharacterSet > * | DoCreateArrayOfCharacterSetsAvailableLC(RFs &, TUint) |
TAvailability | DoPrepareToConvertToOrFromL(TUint, const CArrayFix< SCharacterSet > *, RFs &) |
TEndianness | EndiannessOfForeignCharacters(const SCnvConversionData &, TEndianness) |
void | ScanForStandardNamesAndMibEnumsL(RFs &) |
void | ScanForStandardNamesAndMibEnumsROMOnlyL(RFs &) |
Public Member Enumerations | |
---|---|
enum | anonymous { EInputConversionFlagAppend = 0x00010000, EInputConversionFlagAllowTruncatedInputNotEvenPartlyConsumable = 0x00020000, EInputConversionFlagStopAtFirstUnconvertibleCharacter = 0x00040000, EInputConversionFlagMustEndInDefaultCharacterSet = 0x00080000, EInputConversionFlagAssumeStartInDefaultCharacterSet = 0x00100000 } |
enum | anonymous { EOutputConversionFlagInputIsTruncated = 0x01000000 } |
enum | anonymous { ELowestThreshold = 25 } |
enum | TAvailability { EAvailable, ENotAvailable } |
enum | TDowngradeForExoticLineTerminatingCharacters { EDowngradeExoticLineTerminatingCharactersToCarriageReturnLineFeed, EDowngradeExoticLineTerminatingCharactersToJustLineFeed } |
enum | TEndianness { ELittleEndian, EBigEndian } |
enum | TError { EErrorIllFormedInput = KErrCorrupt } |
Private Member Enumerations | |
---|---|
enum | anonymous { EStoredFlagOwnsConversionData = 0x00000001, EStoredFlagConversionPlugInLibraryIsLoaded = 0x00000002 } |
enum | TCharacterSetSearch { EStopCharacterSetSearch, EContinueCharacterSetSearch } |
enum | TConversionPlugInFunctionOrdinals { EReplacementForUnconvertibleUnicodeCharacters = 1, EConvertFromUnicode = 2, EConvertToUnicode = 3, EIsInThisCharacterSet = 4 } |
TCharacterSetSearch | AppendHardCodedCharacterSetIfRequiredL | ( | CArrayFix< SCharacterSet > & | aArrayOfCharacterSets, |
TUint | aIdentifierOfOnlyCharacterSetOfInterest, | |||
TUint | aIdentifierOfHardCodedCharacterSet, | |||
const TDesC & | aNameOfHardCodedCharacterSet | |||
) | [private, static] |
CArrayFix< SCharacterSet > & aArrayOfCharacterSets | |
TUint aIdentifierOfOnlyCharacterSetOfInterest | |
TUint aIdentifierOfHardCodedCharacterSet | |
const TDesC & aNameOfHardCodedCharacterSet |
IMPORT_C void | AutoDetectCharSetL | ( | TInt & | aConfidenceLevel, |
TUint & | aCharacterSetIdentifier, | |||
const CArrayFix< SCharacterSet > & | aArrayOfCharacterSetsAvailable, | |||
const TDesC8 & | aSample | |||
) |
TInt & aConfidenceLevel | |
TUint & aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > & aArrayOfCharacterSetsAvailable | |
const TDesC8 & aSample |
IMPORT_C void | AutoDetectCharacterSetL | ( | TInt & | aConfidenceLevel, |
TUint & | aCharacterSetIdentifier, | |||
const CArrayFix< SCharacterSet > & | aArrayOfCharacterSetsAvailable, | |||
const TDesC8 & | aSample | |||
) | [static] |
TInt & aConfidenceLevel | |
TUint & aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > & aArrayOfCharacterSetsAvailable | |
const TDesC8 & aSample |
IMPORT_C TInt | ConvertCharacterSetIdentifierToMibEnumL | ( | TUint | aCharacterSetIdentifier, |
RFs & | aFileServerSession | |||
) |
IMPORT_C HBufC8 * | ConvertCharacterSetIdentifierToStandardNameL | ( | TUint | aCharacterSetIdentifier, |
RFs & | aFileServerSession | |||
) |
IMPORT_C TInt | ConvertFromUnicode | ( | TDes8 & | aForeign, |
const TDesC16 & | aUnicode | |||
) | const |
IMPORT_C TInt | ConvertFromUnicode | ( | TDes8 & | aForeign, |
const TDesC16 & | aUnicode, | |||
TInt & | aNumberOfUnconvertibleCharacters | |||
) | const |
IMPORT_C TInt | ConvertFromUnicode | ( | TDes8 & | aForeign, |
const TDesC16 & | aUnicode, | |||
TInt & | aNumberOfUnconvertibleCharacters, | |||
TInt & | aIndexOfFirstUnconvertibleCharacter | |||
) | const |
IMPORT_C TInt | ConvertFromUnicode | ( | TDes8 & | aForeign, |
const TDesC16 & | aUnicode, | |||
TArrayOfAscendingIndices & | aIndicesOfUnconvertibleCharacters | |||
) | const |
TDes8 & aForeign | |
const TDesC16 & aUnicode | |
TArrayOfAscendingIndices & aIndicesOfUnconvertibleCharacters |
IMPORT_C TUint | ConvertMibEnumOfCharacterSetToIdentifierL | ( | TInt | aMibEnumOfCharacterSet, |
RFs & | aFileServerSession | |||
) |
IMPORT_C TUint | ConvertStandardNameOfCharacterSetToIdentifierL | ( | const TDesC8 & | aStandardNameOfCharacterSet, |
RFs & | aFileServerSession | |||
) |
IMPORT_C TInt | ConvertToUnicode | ( | TDes16 & | aUnicode, |
const TDesC8 & | aForeign, | |||
TInt & | aState | |||
) | const |
IMPORT_C TInt | ConvertToUnicode | ( | TDes16 & | aUnicode, |
const TDesC8 & | aForeign, | |||
TInt & | aState, | |||
TInt & | aNumberOfUnconvertibleCharacters | |||
) | const |
IMPORT_C TInt | ConvertToUnicode | ( | TDes16 & | aUnicode, |
const TDesC8 & | aForeign, | |||
TInt & | aState, | |||
TInt & | aNumberOfUnconvertibleCharacters, | |||
TInt & | aIndexOfFirstByteOfFirstUnconvertibleCharacter | |||
) | const |
IMPORT_C void | ConvertibleToCharSetL | ( | TInt & | aConfidenceLevel, |
const TUint | aCharacterSetIdentifier, | |||
const CArrayFix< SCharacterSet > & | aArrayOfCharacterSetsAvailable, | |||
const TDesC8 & | aSample | |||
) |
TInt & aConfidenceLevel | |
const TUint aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > & aArrayOfCharacterSetsAvailable | |
const TDesC8 & aSample |
IMPORT_C void | ConvertibleToCharacterSetL | ( | TInt & | aConfidenceLevel, |
const TUint | aCharacterSetIdentifier, | |||
const CArrayFix< SCharacterSet > & | aArrayOfCharacterSetsAvailable, | |||
const TDesC8 & | aSample | |||
) | [static] |
TInt & aConfidenceLevel | |
const TUint aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > & aArrayOfCharacterSetsAvailable | |
const TDesC8 & aSample |
IMPORT_C CArrayFix< SCharacterSet > * | CreateArrayOfCharacterSetsAvailableL | ( | RFs & | aFileServerSession | ) | [static] |
RFs & aFileServerSession |
IMPORT_C CArrayFix< SCharacterSet > * | CreateArrayOfCharacterSetsAvailableLC | ( | RFs & | aFileServerSession | ) | [static] |
RFs & aFileServerSession |
void | DeleteConversionData | ( | const SCnvConversionData * | aConversionData | ) | [private, static] |
const SCnvConversionData * aConversionData |
void | DeleteConversionData | ( | TAny * | aConversionData | ) | [private, static] |
TAny * aConversionData |
IMPORT_C TInt | DoConvertFromUnicode | ( | const SCnvConversionData & | aConversionData, |
TEndianness | aDefaultEndiannessOfForeignCharacters, | |||
const TDesC8 & | aReplacementForUnconvertibleUnicodeCharacters, | |||
TDes8 & | aForeign, | |||
const TDesC16 & | aUnicode, | |||
TArrayOfAscendingIndices & | aIndicesOfUnconvertibleCharacters | |||
) | [static] |
const SCnvConversionData & aConversionData | |
TEndianness aDefaultEndiannessOfForeignCharacters | |
const TDesC8 & aReplacementForUnconvertibleUnicodeCharacters | |
TDes8 & aForeign | |
const TDesC16 & aUnicode | |
TArrayOfAscendingIndices & aIndicesOfUnconvertibleCharacters |
IMPORT_C TInt | DoConvertFromUnicode | ( | const SCnvConversionData & | aConversionData, |
TEndianness | aDefaultEndiannessOfForeignCharacters, | |||
const TDesC8 & | aReplacementForUnconvertibleUnicodeCharacters, | |||
TDes8 & | aForeign, | |||
const TDesC16 & | aUnicode, | |||
TArrayOfAscendingIndices & | aIndicesOfUnconvertibleCharacters, | |||
TUint & | aOutputConversionFlags, | |||
TUint | aInputConversionFlags | |||
) | [static] |
const SCnvConversionData & aConversionData | |
TEndianness aDefaultEndiannessOfForeignCharacters | |
const TDesC8 & aReplacementForUnconvertibleUnicodeCharacters | |
TDes8 & aForeign | |
const TDesC16 & aUnicode | |
TArrayOfAscendingIndices & aIndicesOfUnconvertibleCharacters | |
TUint & aOutputConversionFlags | |
TUint aInputConversionFlags |
IMPORT_C TInt | DoConvertToUnicode | ( | const SCnvConversionData & | aConversionData, |
TEndianness | aDefaultEndiannessOfForeignCharacters, | |||
TDes16 & | aUnicode, | |||
const TDesC8 & | aForeign, | |||
TInt & | aNumberOfUnconvertibleCharacters, | |||
TInt & | aIndexOfFirstByteOfFirstUnconvertibleCharacter | |||
) | [static] |
const SCnvConversionData & aConversionData | |
TEndianness aDefaultEndiannessOfForeignCharacters | |
TDes16 & aUnicode | |
const TDesC8 & aForeign | |
TInt & aNumberOfUnconvertibleCharacters | |
TInt & aIndexOfFirstByteOfFirstUnconvertibleCharacter |
IMPORT_C TInt | DoConvertToUnicode | ( | const SCnvConversionData & | aConversionData, |
TEndianness | aDefaultEndiannessOfForeignCharacters, | |||
TDes16 & | aUnicode, | |||
const TDesC8 & | aForeign, | |||
TInt & | aNumberOfUnconvertibleCharacters, | |||
TInt & | aIndexOfFirstByteOfFirstUnconvertibleCharacter, | |||
TUint & | aOutputConversionFlags, | |||
TUint | aInputConversionFlags | |||
) | [static] |
CArrayFix< SCharacterSet > * | DoCreateArrayOfCharacterSetsAvailableLC | ( | RFs & | aFileServerSession, |
TUint | aIdentifierOfOnlyCharacterSetOfInterest | |||
) | [private, static] |
TAvailability | DoPrepareToConvertToOrFromL | ( | TUint | aCharacterSetIdentifier, |
const CArrayFix< SCharacterSet > * | aArrayOfCharacterSetsAvailable, | |||
RFs & | aFileServerSession | |||
) | [private] |
TUint aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > * aArrayOfCharacterSetsAvailable | |
RFs & aFileServerSession |
TEndianness | EndiannessOfForeignCharacters | ( | const SCnvConversionData & | aConversionData, |
TEndianness | aDefaultEndiannessOfForeignCharacters | |||
) | [private, static] |
const SCnvConversionData & aConversionData | |
TEndianness aDefaultEndiannessOfForeignCharacters |
TDowngradeForExoticLineTerminatingCharacters | GetDowngradeForExoticLineTerminatingCharacters | ( | ) | [inline] |
IMPORT_C void | PrepareToConvertToOrFromL | ( | TUint | aCharacterSetIdentifier, |
const CArrayFix< SCharacterSet > & | aArrayOfCharacterSetsAvailable, | |||
RFs & | aFileServerSession | |||
) |
TUint aCharacterSetIdentifier | |
const CArrayFix< SCharacterSet > & aArrayOfCharacterSetsAvailable | |
RFs & aFileServerSession |
IMPORT_C TAvailability | PrepareToConvertToOrFromL | ( | TUint | aCharacterSetIdentifier, |
RFs & | aFileServerSession | |||
) |
void | ScanForStandardNamesAndMibEnumsL | ( | RFs & | aFileServerSession | ) | [private] |
RFs & aFileServerSession |
void | ScanForStandardNamesAndMibEnumsROMOnlyL | ( | RFs & | aFileServerSession | ) | [private] |
RFs & aFileServerSession |
IMPORT_C void | SetDefaultEndiannessOfForeignCharacters | ( | TEndianness | aEndianness | ) |
TEndianness aEndianness |
IMPORT_C void | SetDowngradeForExoticLineTerminatingCharacters | ( | TDowngradeForExoticLineTerminatingCharacters | aDowngradeForExoticLineTerminatingCharacters | ) |
TDowngradeForExoticLineTerminatingCharacters aDowngradeForExoticLineTerminatingCharacters |
IMPORT_C void | SetReplacementForUnconvertibleUnicodeCharactersL | ( | const TDesC8 & | aReplacementForUnconvertibleUnicodeCharacters | ) |
const TDesC8 & aReplacementForUnconvertibleUnicodeCharacters |
Output flag used to indicate whether or not a character in the source descriptor is the first half of a surrogate pair, but is the last character in the descriptor to convert.
Note: This enumeration can be used in the DoConvertToUnicode() and DoConvertFromUnicode() functions. These are part of the Character Conversion Plug-in Provider API and are for use by plug-in conversion libraries only. 6.0
EInputConversionFlagAppend = 0x00010000 |
Appends the converted text to the output descriptor. |
EInputConversionFlagAllowTruncatedInputNotEvenPartlyConsumable = 0x00020000 |
By default, when the input descriptor passed to DoConvertFromUnicode() or DoConvertToUnicode() consists of nothing but a truncated sequence, the error-code EErrorIllFormedInput is returned. If this behaviour is undesirable, the input flag EInputConversionFlagAllowTruncatedInputNotEvenPartlyConsumable should be set. |
EInputConversionFlagStopAtFirstUnconvertibleCharacter = 0x00040000 |
Stops converting when the first unconvertible character is reached. |
EInputConversionFlagMustEndInDefaultCharacterSet = 0x00080000 |
Appends the default character set Escape sequence at end of converted text |
EInputConversionFlagAssumeStartInDefaultCharacterSet = 0x00100000 |
EOutputConversionFlagInputIsTruncated = 0x01000000 |
Indicates whether or not the source descriptor ends in a truncated sequence, e.g. the first half only of a surrogate pair. |
ELowestThreshold = 25 |
The lowest confidence value for a character set accepted by Autodetect |
EStoredFlagOwnsConversionData = 0x00000001 | |
EStoredFlagConversionPlugInLibraryIsLoaded = 0x00000002 |
Indicates whether a character set is available or unavailable for conversion. Used by the second overload of PrepareToConvertToOrFromL().
EAvailable |
The requested character set can be converted. |
ENotAvailable |
The requested character set cannot be converted. |
EReplacementForUnconvertibleUnicodeCharacters = 1 | |
EConvertFromUnicode = 2 | |
EConvertToUnicode = 3 | |
EIsInThisCharacterSet = 4 |
Downgrade for line and paragraph separators
EDowngradeExoticLineTerminatingCharactersToCarriageReturnLineFeed |
Paragraph/line separators should be downgraded (if necessary) into carriage return and line feed pairs. |
EDowngradeExoticLineTerminatingCharactersToJustLineFeed |
Paragraph/line separators should be downgraded (if necessary) into a line feed only. |
Specifies the default endian-ness of the current character set. Used by SetDefaultEndiannessOfForeignCharacters().
ELittleEndian |
The character set is big-endian. |
EBigEndian |
The character set is little-endian. |
Conversion error flags. At this stage there is only one error flag- others may be added in the future.
EErrorIllFormedInput = KErrCorrupt |
The input descriptor contains a single corrupt character. This might occur when the input descriptor only contains some of the bytes of a single multi-byte character. |
TUint | iCharacterSetIdentifierOfLoadedConversionData | [private] |
TEndianness | iDefaultEndiannessOfForeignCharacters | [private] |
TDowngradeForExoticLineTerminatingCharacters | iDowngradeForExoticLineTerminatingCharacters | [private] |
TBool | iIsSystemStandardNamesAndMibEnumsScanned | [private] |
TBuf8< KMaximumLengthOfReplacementForUnconvertibleUnicodeCharacters > | iReplacementForUnconvertibleUnicodeCharacters | [private] |