Questions tagged [char8-t]

The C and C++ char8_t standard type represents a character in UTF-8 encoding. Available in C++ from C++20 and in C from C23.

7 questions
10
votes
1 answer

What's the MSVC equivalent for -fno-char8_t?

In C++20 u8 string literals are based on the char8_t type. They deliberately do not convert to char const* any more: const char* str = u8"Hall\u00f6chen \u2603"; // no longer valid in C++20 Of course, the ultimate goal when migrating to C++20 is to…
Tobi
  • 2,591
  • 15
  • 34
3
votes
3 answers

Copy a std::u8string into a c-style string of utf8 characters

Copying a string with no encodage into a c-string is quite easy: auto to_c_str(std::string const& str) -> char* { auto dest = new char[str.size() + 1]; return strcpy(dest, str.c_str()); } But how can I do that with a std::u8string? Is there…
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
2
votes
2 answers

Is there a char8_t in C?

I have searched in many sites and did not get anything. I know that char8_t is a keyword in C++ since C++20. I am trying to find out in C, are they typedef-ing unsigned char to char8_t in C23 (with the release of u8 character literals). Can anyone…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
0
votes
1 answer

Escape sequences for char8_t and unsigned char

Trying to use escape sequences to construct a char8_t string (to not rely on file/compiler encoding), I got issue with MSVC. I wonder if it is a bug, or if it is implemention dependent. Is there a workaround? constexpr char8_t s1[] = …
Jarod42
  • 203,559
  • 14
  • 181
  • 302
0
votes
1 answer

char8 & uchar8 Equivalent

I am working on a program, or I communicate with a card via UDP, the answers of the card I recover them in a Byte table and I put them in an int32 but they ask me that the gain be coded in uchar8 and Pedestal in char8, what is it the equivalent of…
0
votes
1 answer

Create std::u8string from std::string/char const* when the latter is already in utf-8

I'm in the process of upgrading my code base to C++20 and would like to make use of std::u8string/char8_t. I'm using a 3rd-party library that takes and returns UTF-8 strings in its API, however it hasn't been updated to C++20 yet and thus takes and…
Corristo
  • 4,911
  • 1
  • 20
  • 36
0
votes
4 answers

Will we have a size_t strlen(const char8_t*) in a future C++ version

char8_t in C++20 fixes some problems of char, so I was considering using char8_t instead of char for utf8 text (e.g. text from command line). But then I noticed that strlen was not specified in the standard to be used with char8_t, actually none of…