Home > Back-end >  For help on converting char * would * C
For help on converting char * would * C

Time:10-29

Code:
 
#include
#include
#include
#include
#include
Int main () {
The setlocale (LC_ALL, "");
Would be WSTR [100].
Char STR [100].
Strcpy (STR, "Chinese test");
Printf (" strlen: % I64d \ n ", strlen (STR));
Size_t len.
Mbstowcs_s (& amp; Len, WSTR, 99, STR, strlen (STR));
If (len<=0) {
Perror (" error ");
} else {
Wprintf (L "length: % ld, conversion: % ls \ n", len, WSTR);
return 0;
}
}

Compile platform: win10 mingw - w64
Execution (compile) the code or error occurs, but if I add parameters at compile time - fexec - charset=GBK is normal, this is how to return a responsibility?
I don't want to let the software limited to deal with Chinese

CodePudding user response:

MultiByteToWideChar

CodePudding user response:

reference 1/f, the truth is right or wrong response:
MultiByteToWideChar

I want to develop cross-platform software

CodePudding user response:

C + + 11 provides a byte wide library, it is suggested that study,

CodePudding user response:

The individual feels C own conversion function is very small, if you want to do the conversion can invoke the iconv library, or write their own conversion code,
Note: printf and wprintf can not call together, this is undefined behavior,

CodePudding user response:

Cross-platform use iconv, anyway, I didn't cross, have been use win32api or MFC A2W simple a batch of

CodePudding user response:

reference 5 floor smwhotjay reply:
cross-platform use iconv, I have been use win32api anyway didn't cross, or a group of simple MFC A2W

Iconv is not confined to the Linux?
  • Related