[libcxx-commits] [libcxx] Implement P1885R12: `<text_encoding>` header (PR #141312)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 24 06:05:38 PDT 2025


================
@@ -0,0 +1,1482 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TEXT_ENCODING_TEXT_ENCODING_H
+#define _LIBCPP___TEXT_ENCODING_TEXT_ENCODING_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_HAS_LOCALIZATION
+
+#  include <__algorithm/copy_n.h>
+#  include <__algorithm/lower_bound.h>
+#  include <__algorithm/min.h>
+#  include <__functional/hash.h>
+#  include <__iterator/iterator_traits.h>
+#  include <__locale_dir/locale_base_api.h>
+#  include <__ranges/view_interface.h>
+#  include <__string/char_traits.h>
+#  include <__utility/unreachable.h>
+#  include <cstdint>
+#  include <string_view>
+
+_LIBCPP_PUSH_MACROS
+#  include <__undef_macros>
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_EXPORTED_FROM_ABI text_encoding {
+  static constexpr size_t max_name_length = 63;
+
+private:
+  struct __encoding_data {
+    using __id_rep _LIBCPP_NODEBUG = int_least32_t;
+    __id_rep __mib_rep;
+    const char* __name;
----------------
philnik777 wrote:

Should we store the size of the name as well? We already have space between `__mib_rep` and `__name` anyways. Also, they should be `__mib_rep_` and `__name_`.

https://github.com/llvm/llvm-project/pull/141312


More information about the libcxx-commits mailing list