Standard C library wchar_t and char conversion character string type

C library functions -  mbstowcs ()

C standard library - <stdlib.h> C standard library - <stdlib.h>

description

C library function  size_t mbstowcs (schar_t * pwcs, const char * str, size_t n)  the parameter  str  convert a string of multi-byte characters pointed parameters  PWCS  pointed array.

statement

Here is the () function declaration mbstowcs.

size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)

parameter

  • PWCS  - points to a wchar_t array, the array of elements is sufficient to store the length of a maximum character length of the wide string.
  • STR  - be converted to multi-byte character string.
  • the n-  - maximum number of characters to be converted.

return value

This function returns the number of characters of the conversion, not including the null character. If you encounter an invalid multi-byte character, a value of -1 is returned.

 

C library functions -  wcstombs ()

C standard library - <stdlib.h> C standard library - <stdlib.h>

description

C library function  size_t wcstombs (char * str, const wchar_t * pwcs, size_t n)  the wide-character string  PWCS  convert a  str  multi-byte string that begins. Up to be  n bytes are written  str  in.

statement

Here is () statement wcstombs function.

size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)

parameter

  • STR  - points to a char array element, there are at least n bytes long.
  • PWCS  - be converted to wide-character string.
  • n-  - to be written to the maximum number of bytes in str.

return value

This function returns the number of bytes written to and converted into str, not including the null character. If you encounter an invalid multi-byte character, a value of -1 is returned.

Guess you like

Origin www.cnblogs.com/zhangdewang/p/11420410.html