From 65a10410e3f722f498d16e6a9fc727c50d1d960d Mon Sep 17 00:00:00 2001 From: sakiodre <136492105+sakiodre@users.noreply.github.com> Date: Thu, 23 Nov 2023 01:09:14 +0700 Subject: [PATCH] Docs: Add suggestion to turn of char8_t behavior for C++20 (#7025) --- docs/FONTS.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/FONTS.md b/docs/FONTS.md index b0876a36..8988fb11 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -404,16 +404,12 @@ ImGui::Text(u8"こんにちは"); // this will always be encoded as UTF-8 ImGui::Text("こんにちは"); // the encoding of this is depending on compiler settings/flags and may be incorrect. ``` -Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char_t*` which doesn't cast to `const char*`. +Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char8_t*` which doesn't cast to `const char*`. Because of type usage of `u8""` in C++20 is a little more tedious: ```cpp ImGui::Text((const char*)u8"こんにちは"); ``` -We suggest using a macro in your codebase: -```cpp -#define U8(_S) (const char*)u8##_S -ImGui::Text(U8("こんにちは")); -``` +However, you can disable this behavior completely using the compiler option [`/Zc:char8_t-`](https://learn.microsoft.com/en-us/cpp/build/reference/zc-char8-t?view=msvc-170) for MSVC and [`-fno-char8_t`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html) for Clang and GCC. ##### [Return to Index](#index) ---------------------------------------