×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    How to Convert TDes to unsigned char*?

    Hi FN

    This may be already asked in a different form. But I've looked all the post I can find about this. Still havent managed to do it.

    So is anybody know how to convert an TDes to an unsigned char*?

    Here is what I need to do?

    Code:
    void (TDes& aKey, const TInt aSize)
    {
    	TInt len = aKey.Length();
    	unsigned char* dest = new unsigned char[len+1];
    	// ??
    	// copy aKey to dest ??
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: How to Convert TDes to unsigned char*?

    Hi,

    TDes16 has method
    IMPORT_C const TUint16 *PtrZ();
    where TUint16 is unsigned short int.

    BR
    STeN

  3. #3
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: How to Convert TDes to unsigned char*?

    Be mindful if you call PtrZ() as the descriptor's length must be less than its max length, also this returns a pointer to the data, not a copy of the data.

    An alternative is

    Mem::Copy(dest, aKey.Ptr(), aKey.Size();

    and if you need to Null terminate it then:

    dest[aKey.Length()] = '\0';

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: How to Convert TDes to unsigned char*?

    You might also need to convert to an 8-bit descriptor first and then use the PtrZ or copy methods described above from there. It depends what sort of data is in your descriptor. If it is basically an ASCII string then I suspect you will want to.

    Sorcery

  5. #5
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: How to Convert TDes to unsigned char*?

    You can find some useful snippets in the wiki. For instance:
    http://wiki.forum.nokia.com/index.ph...and_Vice_Versa

  6. #6
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Re: How to Convert TDes to unsigned char*?

    Hi FN


    Thank you very much for the replies . Succeded converting

    Found another page about this on the wiki

    http://wiki.forum.nokia.com/index.ph..._to_Descriptor

Similar Threads

  1. Replies: 1
    Last Post: 2007-12-06, 10:23
  2. C-code..unable to make sis
    By Symbian_Neil in forum Symbian
    Replies: 9
    Last Post: 2006-12-02, 07:55
  3. convert a TDes to TBuf8
    By kcome in forum Symbian
    Replies: 1
    Last Post: 2003-05-27, 19:42
  4. convert a TDes to TBuf8
    By kcome in forum Symbian
    Replies: 3
    Last Post: 2003-05-26, 09:41
  5. How to convert TLex to TDes?
    By Marw_Work in forum Symbian
    Replies: 1
    Last Post: 2002-06-04, 05:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×