Home > Back-end >  Could you tell me how to under the multibyte character set to solve this problem
Could you tell me how to under the multibyte character set to solve this problem

Time:11-25

 
Would the STR [20].
InputBox (STR, 10, L "please enter the number of words");
Set_num=_wtoi (STR);


Because my project many function under multiple character set to use, but this function can only be used under the UNICODE, could you tell me how to solve this error in a project,

CodePudding user response:

Or, how in a project with a piece of code undef UNICODE in the project after another use UNICODE code,

CodePudding user response:

Or, how to write an input box, multiple character sets.

CodePudding user response:

The two would be and char conversion function don't have to,
 STD: : wstring char2wchar (const char * c, size_t=CP_ACP m_encode/* */) 
{
STD: : wstring STR.
Int len=: : MultiByteToWideChar (m_encode, 0, c, strlen (c), NULL, 0).
Would be * m_wchar=new would [len + 1];
: : MultiByteToWideChar (m_encode, 0, c, strlen (c), m_wchar, len);
M_wchar [len]='\ 0';
STR=m_wchar;
The delete m_wchar;
return str;
}

STD: : string wchar2char (const would * wp, size_t=CP_ACP m_encode/* */)
{
STD: : string STR.
Int len=: : WideCharToMultiByte (m_encode, 0, wp, wcslen (wp), NULL, 0, NULL, NULL);
Char * m_char=new char [len + 1];
: : WideCharToMultiByte (m_encode, 0, wp, wcslen (wp), m_char, len, NULL, NULL);
M_char [len]='\ 0';
STR=m_char;
The delete m_char;
return str;
}


The function USES to similar as follows:
Char * STR="please enter the number of words";
String s=char2wchar (STR);
Char str1 [20].
InputBox (str1, strlen (s) + 1, s.c _str);

CodePudding user response:

reference little_cat123 reply: 3/f
the two would be and char conversion function don't have to,
 STD: : wstring char2wchar (const char * c, size_t=CP_ACP m_encode/* */) 
{
STD: : wstring STR.
Int len=: : MultiByteToWideChar (m_encode, 0, c, strlen (c), NULL, 0).
Would be * m_wchar=new would [len + 1];
: : MultiByteToWideChar (m_encode, 0, c, strlen (c), m_wchar, len);
M_wchar [len]='\ 0';
STR=m_wchar;
The delete m_wchar;
return str;
}

STD: : string wchar2char (const would * wp, size_t=CP_ACP m_encode/* */)
{
STD: : string STR.
Int len=: : WideCharToMultiByte (m_encode, 0, wp, wcslen (wp), NULL, 0, NULL, NULL);
Char * m_char=new char [len + 1];
: : WideCharToMultiByte (m_encode, 0, wp, wcslen (wp), m_char, len, NULL, NULL);
M_char [len]='\ 0';
STR=m_char;
The delete m_char;
return str;
}


The function USES to similar as follows:
Char * STR="please enter the number of words";
String s=char2wchar (STR);
Char str1 [20].
InputBox (str1, strlen (s) + 1, s.c _str);
brother, mark the first, tomorrow I try,

CodePudding user response:

@ little_cat123 brother this with ah, you,

CodePudding user response:

refer to fifth floor Harris - H reply:
@ little_cat123 brother you ah,,
string is char * to nature, with char2wchar returns the wstring (nature would be *), inputBox function character variables are char *, I think you are using would be * to statement string, if you use char * directly, don't need to transform function,
  • Related