Symbian data type conversion

Source: Internet
Author: User
Data Type Conversion

1. String to Digit
Tbuf16 <20> Buf (_ L ("123 "));
Tlex Lex (BUF );
Tint inum;
Lex. Val (inum );
2. Convert numbers into strings
Tbuf16 <20> Buf;
Tint inum = 20;
Buf. Format (_ L ("% d"), inum );
3.Convert a Symbian string to a char string
Char * P = NULL;
Tbuf8 <20> Buf (_ L ("AAAAA "));
P = (char *) BUF. PTR ();
4. UTF-8 to Unicode
Cnvutfconverter: converttounicodefromutf8 (ibuf16, ibuf8 );
5. Unicode conversion to UTF-8
Cnvutfconverter: convertfromunicodetoutf8 (ibuf8, ibuf16 );
6. Convert a char string to a Symbian string
Char * Cc = "aaaa ";
A. Set (const tuint8 *) CC, strlen (CC ));

Add one more:
Tdesc8 & Buf;
Tuint8 * pdata;
Pdata = Buf. PTR ();
Then, this pdata can be used as an unsigned char *, which is important for network communication.
If pdata is damaged, you can
Tbuf8 <1024> tmp_buf;
Tmp_buf.copy (BUF );
Pdata = tmp_buf.ptr ();
In this way, you can protect the data of the Buf, especially if the data received by the socket is allocated by the receiving function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.