Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      char16_t

      From cppreference.com
      <c‎ |string‎ |multibyte
       
       
       
       
      Defined in header<uchar.h>
      typedefuint_least16_t char16_t;
      (since C11)

      char16_t is an unsigned integer type used for 16-bit wide characters and is the same type asuint_least16_t.

      Contents

      [edit]Notes

      On any given platform, by the definition ofuint_least16_t, the width of typechar16_t can be greater than 16 bits, but the actual values stored in an object of typechar16_t will always have a width of 16 bits.

      [edit]Example

      Run this code
      #include <stdio.h>#include <uchar.h> int main(void){const char16_t wcs[]= u"zß水🍌";// or "z\u00df\u6c34\U0001f34c"constsize_t wcs_sz=sizeof wcs/sizeof*wcs;printf("%zu UTF-16 code units: [ ", wcs_sz);for(size_t n=0; n< wcs_sz;++n)printf("%#x ", wcs[n]);printf("]\n");}

      Possible output:

      6 UTF-16 code units: [ 0x7a 0xdf 0x6c34 0xd83c 0xdf4c 0 ]

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.28 Unicode utilities <uchar.h> (p: 292)
      • 7.20.1.2 Minimum-width integer types (p: 212-213)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.28 Unicode utilities <uchar.h> (p: 398)
      • 7.20.1.2 Minimum-width integer types (p: 290)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.18.1.2 Minimum-width integer types (p: 256)

      [edit]See also

      C++ documentation forFundamental types
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/string/multibyte/char16_t&oldid=149702"

      [8]ページ先頭

      ©2009-2025 Movatter.jp