Conversion between wchar_t and hbufc in Symbian

Source: Internet
Author: User

Http://blog.csdn.net/lihao_ningxia/archive/2008/09/24/2972676.aspx

 

Conversion between wchar_t and hbufc in Symbian

// Head file:
Const wchar_t * buftonewwchar (const tdesc & ainput );
Hbufc * wchartonewbuf (const wchar_t * ainput );

 

// CPP File
Wchar_t * wcsncpy (wchar_t * DST, const wchar_t * SRC, size_t count ){
Memcpy (DST, SRC, count * sizeof (wchar_t ));
Return DST;
}

Wchar * wstrdup (const wchar * s, size_t Len)
{
If (! S)
Return NULL;
Int L = (LEN = stringdup_nolen )? Wcslen (s): Len;
Wchar * news = new wchar [L + 1];
Wcsncpy (News, S, L );
News [l] = 0;
Return news;
}

Const wchar_t * buftonewwchar (const tdesc & ainput)
{
// This allocates a new wchar_t * Buffer
Wchar_t * ret = wstrdup (const wchar_t *) ainput. PTR (), ainput. Length ());
Return (const wchar_t *) ret;
}
Hbufc * wchartonewbuf (const wchar_t * ainput)
{
Int Len = wcslen (ainput );
Tuint16 * wchars = (tuint16 *) ainput;

Rbuf16 buf16;
Buf16.createl (LEN );
Buf16.copy (wchars );

Return buf16.alloc ();
}

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: info-contact@alibabacloud.com 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.