Difference between revisions of "cpp/string/multibyte/mbrtoc16"
(+) |
m (typo) |
||
Line 28: | Line 28: | ||
* {{cpp|0}} if the character converted from {{tt|s}} (and stored in {{cpp|*pc16}} if non-null) was the null character | * {{cpp|0}} if the character converted from {{tt|s}} (and stored in {{cpp|*pc16}} if non-null) was the null character | ||
* the number of bytes {{cpp|[1...n]}} of the multibyte character successfully converted from {{tt|s}} | * the number of bytes {{cpp|[1...n]}} of the multibyte character successfully converted from {{tt|s}} | ||
− | * {{cpp|static_cast<std::size_t>(-3)}} if | + | * {{cpp|static_cast<std::size_t>(-3)}} if the next {{cpp|char16_t}} from a multi-{{cpp|char16_t}} character (e.g. a surrogate pair) has now been written to {{cpp|*pc16}} |
* {{cpp|static_cast<std::size_t>(-2)}} if the next {{tt|n}} bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to {{cpp|*pc16}}. | * {{cpp|static_cast<std::size_t>(-2)}} if the next {{tt|n}} bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to {{cpp|*pc16}}. | ||
* {{cpp|static_cast<std::size_t>(-1)}} if encoding error occurs. Nothing is written to {{tt|*pc16}}, the value {{cpp|EILSEQ}} is stored in {{cpp|errno}} and the value if {{cpp|*ps}} is unspecified. | * {{cpp|static_cast<std::size_t>(-1)}} if encoding error occurs. Nothing is written to {{tt|*pc16}}, the value {{cpp|EILSEQ}} is stored in {{cpp|errno}} and the value if {{cpp|*ps}} is unspecified. |
Revision as of 21:45, 7 December 2011
Template:cpp/string/multibyte/sidebar
Defined in header <cuchar>
|
||
std::size_t mbrtoc16( char16_t* pc16, const char* s, std::size_t n, std::mbstate_t* ps); |
||
Converts a narrow multibyte character to a 16-bit wide character.
If s
is not a null pointer, inspects at most n
bytes of the multibyte character string, beginning with the byte pointed to by s
to determine the number of bytes necessary to complete the next multibyte character (including any shift sequences). If the function determines that the next multibyte character in s
is complete and valid, converts it to the corresponding 16-bit character and stores it in Template:cpp (if pc16
is not null).
If s
is a null pointer, the values of n
and pc16
are ignored and call is equivalent to Template:cpp.
If the wide character produces is the null character, the shift state Template:cpp is reset to initial shift state.
If the macro Template:cpp is defined, the 16-bit encoding used by this function is UTF-16, otherwise it is implementation-defined.
Parameters
pc16 | - | pointer to the location where the resulting 16-bit character will be written |
s | - | pointer to the multibyte character string used as input |
n | - | limit on the number of bytes in s that can be examined |
ps | - | pointer to the shift state used when interpreting the multibyte string |
Return value
The first of the following that applies:
- Template:cpp if the character converted from
s
(and stored in Template:cpp if non-null) was the null character - the number of bytes Template:cpp of the multibyte character successfully converted from
s
- Template:cpp if the next Template:cpp from a multi-Template:cpp character (e.g. a surrogate pair) has now been written to Template:cpp
- Template:cpp if the next
n
bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to Template:cpp. - Template:cpp if encoding error occurs. Nothing is written to
*pc16
, the value Template:cpp is stored in Template:cpp and the value if Template:cpp is unspecified.
See also
(C++11) |
convert a 16-bit wide character to narrow multibyte string (function) |