From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/string%2Fmultibyte%2Fchar16_t.html | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 devdocs/c/string%2Fmultibyte%2Fchar16_t.html (limited to 'devdocs/c/string%2Fmultibyte%2Fchar16_t.html') diff --git a/devdocs/c/string%2Fmultibyte%2Fchar16_t.html b/devdocs/c/string%2Fmultibyte%2Fchar16_t.html new file mode 100644 index 00000000..b31287af --- /dev/null +++ b/devdocs/c/string%2Fmultibyte%2Fchar16_t.html @@ -0,0 +1,35 @@ +

char16_t

Defined in header <uchar.h>
typedef uint_least16_t char16_t;
+
(since C11)

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

+

Notes

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

+

Example

#include <stdio.h>
+#include <uchar.h>
+ 
+int main(void)
+{
+    const char16_t wcs[] = u"zß水🍌"; // or "z\u00df\u6c34\U0001f34c"
+    const size_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 ]

References

See also

+
C++ documentation for Fundamental types
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/string/multibyte/char16_t +

+
-- cgit v1.2.3