Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::c8rtomb

      From cppreference.com
      <cpp‎ |string‎ |multibyte
       
       
       
       
      Defined in header<cuchar>
      std::size_t c8rtomb(char* s, char8_t c8,std::mbstate_t* ps);
      (since C++20)

      Converts a single code point from UTF-8 to a narrow multibyte character representation.

      Ifs is not a null pointer andc8 is the last code unit in a valid UTF-8 encoding of a code point, the function determines the number of bytes necessary to store the multibyte character representation of that code point (including any shift sequences, and taking into account the current multibyte conversion state*ps), and stores the multibyte character representation in the character array whose first element is pointed to bys, updating*ps as necessary. At mostMB_CUR_MAX bytes can be written by this function.

      Ifc8 is not the final UTF-8 code unit in a representation of a code point, the function does not write to the array pointed to bys, only*ps is updated.

      Ifs is a null pointer, the call is equivalent tostd::c8rtomb(buf, u8'\0', ps) for some internal bufferbuf.

      Ifc8 is the null characteru8'\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.

      The multibyte encoding used by this function is specified by the currently active C locale.

      Contents

      [edit]Parameters

      s - pointer to narrow character array where the multibyte character will be stored
      c8 - the UTF-8 code unit to convert
      ps - pointer to the conversion state object used when interpreting the multibyte string

      [edit]Return value

      The number of bytes stored in the array object (including any shift sequences). This may be zero whenc8 is not the final code unit in the UTF-8 representation of a code point.

      Ifc8 is invalid (does not contribute to a sequence ofchar8_t corresponding to a valid multibyte character), the value of the macroEILSEQ is stored inerrno,static_cast<std::size_t>(-1) is returned, and the conversion state is unspecified.

      [edit]Notes

      Calls toc8rtomb with a null pointer argument fors may introduce a data race with other calls toc8rtomb with a null pointer argument fors.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      (C++20)
      converts a narrow multibyte character to UTF-8 encoding
      (function)[edit]
      (C++11)
      converts a UTF-16 character to narrow multibyte encoding
      (function)[edit]
      C documentation forc8rtomb
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/string/multibyte/c8rtomb&oldid=177815"

      [8]ページ先頭

      ©2009-2025 Movatter.jp