C ++ encoding conversion generic class

Source: Internet
Author: User

Related content:

C ++ Implements Five methods for converting char * To BSTR

C ++ implements two methods for converting BSTR to char *

C ++ achieves conversion between ANSI encoding and Unicode encoding

C ++ achieves interchange between UTF-8 encoding and Unicode encoding

C ++ encoding conversion generic classes for your reference. The contents of the head file wide_string.h are as follows:

Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/--> /*
* Wide string
*/
Class WideString
{

// Wchar_t;
Wchar_t * ws;
// Initialization
Void init (char *, unsigned int );

Public:
/*
* Constructor converts the input string to wchar_t;
*/
WideString (char *);
/*
* Constructor converts the input string to wchar_t;
*/
WideString (char *, unsigned int );
/*
* Destructor to release wchar_t;
*/
~ WideString ();
/*
* Convert to a UTF-8 string
*/
Void toUTF8String (char *);
/*
* Get the length of the UTF-8 string
*/
Unsigned int getUTF8StringLength ();
/*
* Convert to the default encoding string
*/
Void toDefaultString (char *);
/*
* Get the default encoding String Length
*/
Unsigned int getdefastrstringlength ();
/*
* Convert to a MultiBytes string
*/
Void toMultiBytesString (char *, unsigned int );
/*
* Get the length of a MultiBytes string
*/
Unsigned int getMultiBytesStringLength (unsigned int );
};

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.