Home > Back-end >  Of new beg for help
Of new beg for help

Time:09-18

How to put the would name1 [5] to char name [5], seek answers,

CodePudding user response:

Allows the information loss? Can not words, for loop transformation assignment is ok; Not possible, you want to want to do a deal compression algorithm, or chat [5] save any would be [5], unless wchat_t size and char, you can use sizeof (would) to confirm it

CodePudding user response:

If English is good

CodePudding user response:

# include & lt; stdio.h>
# include & lt; Stdlib. H>

# define BUFFER_SIZE 50

Int main ()
{
Size_t ret.
Char * MB=(char *) malloc (BUFFER_SIZE);
Would be * WC=L "http://www.w3cschool.cc";

Wide character string */*/
Ret=wcstombs (MB, WC, BUFFER_SIZE);

Printf (" want to convert the number of characters=% u \ n ", ret);
Printf (" multi-byte character=% s \ n \ n ", MB).

Return (0);
}

CodePudding user response:

Is English, I try the method of

CodePudding user response:

 
//Unicode ACSII
String UnicodeToAcsii (const wstring& Unicode_string)
{
String acsii_string;

//CP_OEMCP - the default to the OEM code page
Int len=WideCharToMultiByte (CP_OEMCP, 0, unicode_string c_str (), 1, NULL, 0, NULL, NULL);
If (ERROR_NO_UNICODE_TRANSLATION==len | | 0==len)
{
//return the empty wstring
Return acsii_string;
}

Vector Vec_result (len);
Int result_len=WideCharToMultiByte (CP_OEMCP, 0, unicode_string c_str (), 1, & amp; Vec_result [0], len, NULL, NULL);
If (result_len!=len)
{
//return the empty wstring
Return acsii_string;
}

Acsii_string=string (& amp; Vec_result [0]);
Return acsii_string;
}
//ACSII Unicode
Wstring AcsiiToUnicode (const string& Acsii_string)
{
Wstring unicode_string;

//CP_ACP - default to ANSI code page
Int len=MultiByteToWideChar (CP_ACP, 0, acsii_string c_str (), 1, NULL, 0).
If (ERROR_NO_UNICODE_TRANSLATION==len | | 0==len)
{
//return the empty wstring
Return unicode_string;
}

VectorInt result_len=MultiByteToWideChar (CP_ACP, 0, acsii_string c_str (), 1, & amp; Vec_result [0], len);
If (result_len!=len)
{
//return the empty wstring
Return unicode_string;
}

Unicode_string=wstring (& amp; Vec_result [0]);
Return unicode_string;
}
  • Related