CopperSpice API  2.0.0
char8_t

C++11 added definitions for char16_t and char32_t. The definition of the data type char8_t was added in C++20. With the addition of this new data type the meaning of the prefix u8 was altered.

String Literal Prefix

A string literal is the formal name for a quoted string. Before C++20 using no prefix before a string literal or using the u8 prefix called the same overloads in QString. The data was considered to be an "array of char elements".

With the release of C++20 the meaning of the u8 prefix changed. The current definition states the data should be treated as an array of char8_t elements.

Example

When creating a new QString if no prefix is specified the encoding of UTF-8 will be assumed.

QString str_1 = "The question of whether computers can think is like the question of whether submarines can swim.";

If the prefix u8 is specified then the encoding is defined and guaranteed to be UTF-8. New overloads where added to QString to handle the different types.

QString str_2 = u8"The computer was born to solve problems that did not exist before.";

Prefix Comparisons

The u and U prefixes were added in C++11 and their definitions have not changed.

Prefix Data Type Encoding
u8 char8_t UTF-8
u char16_t UTF-16
U char32_t UTF-32