Converting text to Unicode text

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: symbianyucca (22 Mar 2007)
Last edited: hamishwillee (20 Jul 2012)

CCnvCharacterSetConverter API is designed to be used when converting texts that is written in some other than Unicode format. Following function shows how it can be used to for text conversions:

void ConvertTextL(const TDesC8& aData,TDes& aText, TUint aConverter)
TInt state = CCnvCharacterSetConverter::KStateDefault;
CCnvCharacterSetConverter* CSConverter =
TPtrC8 Remainder(aData);
if (CSConverter->PrepareToConvertToOrFromL(aConverter,iFs) !=
const TInt returnValue =
if (returnValue <= 0) // < error

aData is used to pass the text as byte buffer, you can get file read to the file buffer for example by using file reading example codes. aText is then used to store the Unicode text, note that with this example caller is responsible on allocating enough long buffer for the aText. aConverter is then character converters identifier, to get this value you could query supported character sets with following function:

CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* CharSets = 
for(TInt i=0; i < CharSets->Count(); i++)
CleanupStack::PopAndDestroy(); // CharSets

Which with you can get the value for aConverter from the Identifier()-function. The Name()-function has the name associated with the converter, this could be the full name for the converters file, or character sets name (like windows-874), to check which one the Name()-function returns, you could use NameIsFileName() function.

Note that supported character sets depends on the device’s model and can vary significantly between different devices. Also TIS-620, is named TIS_620 quite often, thus if you require some specific character converter to be present, you should check it manually from all target devices.

This page was last modified on 20 July 2012, at 10:20.
32 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.