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%2Fchar8_t.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 devdocs/c/string%2Fmultibyte%2Fchar8_t.html (limited to 'devdocs/c/string%2Fmultibyte%2Fchar8_t.html') diff --git a/devdocs/c/string%2Fmultibyte%2Fchar8_t.html b/devdocs/c/string%2Fmultibyte%2Fchar8_t.html new file mode 100644 index 00000000..56ae4d71 --- /dev/null +++ b/devdocs/c/string%2Fmultibyte%2Fchar8_t.html @@ -0,0 +1,24 @@ +

char8_t

Defined in header <uchar.h>
typedef unsigned char char8_t;
+
(since C23)

char8_t is an unsigned integer type used for UTF-8 and is the same type as unsigned char.

+

Example

#include <uchar.h>
+#include <stdio.h>
+ 
+int main(void)
+{
+    char8_t str[] = u8"zß水🍌"; // or "z\u00df\u6c34\U0001f34c"
+    size_t str_sz = sizeof str; // sizeof *str == 1 by definition
+    printf("%zu UTF-8 code units: [ ", str_sz);
+    for (size_t n = 0; n < str_sz; ++n)
+        printf("%02X ", str[n]);
+    printf("]\n");
+}

Possible output:

+
11 UTF-8 code units: [ 7A C3 9F E6 B0 B4 F0 9F 8D 8C 00 ]

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/char8_t +

+
-- cgit v1.2.3