Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/string/multibyte/c32rtomb"

From cppreference.com
< cpp‎ | string‎ | multibyte
m (Corrected the wrong function name(c16rtomb->c32rtomb).)
(+see c)
Line 2: Line 2:
 
{{cpp/string/multibyte/navbar}}
 
{{cpp/string/multibyte/navbar}}
 
{{ddcl | header=cuchar | notes={{mark since c++11}} |
 
{{ddcl | header=cuchar | notes={{mark since c++11}} |
std::size_t c32rtomb( char* s, char32_t c32, std::mbstate_t* ps);
+
std::size_t c32rtomb( char* s, char32_t c32, std::mbstate_t* ps );
 
}}
 
}}
  
Line 31: Line 31:
 
{{dcl list template | cpp/string/multibyte/dcl list mbrtoc32}}
 
{{dcl list template | cpp/string/multibyte/dcl list mbrtoc32}}
 
{{dcl list template | cpp/locale/codecvt/dcl list do_out | mem=std::codecvt<char32_t, char, std::mbstate_t>}}
 
{{dcl list template | cpp/locale/codecvt/dcl list do_out | mem=std::codecvt<char32_t, char, std::mbstate_t>}}
 +
{{dcl list see c | c/string/multibyte/c32rtomb}}
 
{{dcl list end}}
 
{{dcl list end}}

Revision as of 12:16, 10 September 2012

Defined in header <cuchar>
std::size_t c32rtomb( char* s, char32_t c32, std::mbstate_t* ps );
(since C++11)

Converts a 32-bit wide character to its narrow multibyte representation.

If s is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of c32 (including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by s. At most MB_CUR_MAX bytes can be written by this function.

If s is a null pointer, the call is equivalent to std::c32rtomb(buf, U'\0', ps) for some internal buffer buf.

If c32 is the null wide character U'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.

If the macro __STDC_UTF_32__ is defined, the 32-bit encoding used by this function is UTF-32, otherwise it is implementation-defined. In any case, the multibyte encoding used by this function is specified by the currently active C locale.

Parameters

s - pointer to narrow character array where the multibyte character will be stored
c32 - the 32-bit character to convert
ps - pointer to the conversion state object used when interpreting the multibyte string

Return value

On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by s. This value may be 0, e.g. when processing the first char32_t in multi-char32_t-character sequence (does not occur in UTF-32).

On failure (if c32 is not a valid 32-bit character), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.

See also

Template:cpp/string/multibyte/dcl list mbrtoc32Template:cpp/locale/codecvt/dcl list do out
C documentation for c32rtomb