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 );
};