Thursday, January 14, 2016
TBUF ask how to convert char * type
I know TBUF8 through the following code conversion
TBuf8 & lt; 256 & gt; utf8;
int len = strlen ((char *) utf8.PtrZ ());
char * p = (char *) malloc (sizeof (char) * (len + 1));
strcpy (p, (char *) utf8.PtrZ ()); // Do not use p = a;
However, when using TBuf only save the first character of it
I use unicode coding, want to use TBuf Is there no experts can give pointers about, thank you
Reply:
There are the following:
void CMcAppUi :: ConvUni2Gbk (TDesC & amp; original, TDes8 & amp; res) {
#ifndef __WINS__
TInt state = CCnvCharacterSetConverter :: KStateDefault;
CCnvCharacterSetConverter * iConv;
iConv = CCnvCharacterSetConverter :: NewLC ();
if (iConv- & gt; PrepareToConvertToOrFromL (KCharacterSetIdentifierGbk,
iEikonEnv- & gt;! FsSession ()) = CCnvCharacterSetConverter :: EAvailable)
User :: Leave (KErrNotSupported);
iConv- & gt; ConvertFromUnicode (res, original, state);
CleanupStack :: PopAndDestroy ();
#else
res.Format (_L8 ("wayne chen% s"), original);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment