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

William Tran-Viet via libcxx-commits libcxx-commits at lists.llvm.org
Sun Nov 16 10:26:04 PST 2025


================
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <text_encoding>
+
+// REQUIRES: std-at-least-c++26
+// REQUIRES: locale.en_US.UTF-8
+// UNSUPPORTED: no-localization
+
+// class locale
+
+// text_encoding encoding() const
+
+// Concerns:
+// 1. Default locale returns a text_encoding representing "ASCII"
+// 2. Locale built with en_US.UTF-8 returns text_encoding representing "UTF-8"
+
+#include <cassert>
+#include <locale>
+#include <text_encoding>
+
+#include "test_macros.h"
+#include "platform_support.h"
+
+using id = std::text_encoding::id;
+
+int main(int, char**) {
+#if false
----------------
smallp-o-p wrote:

Test for `locale::encoding()`, which I don't envision being able to implement in this PR. Wasn't sure whether to remove it or leave it in for the future. I do remember seeing similar tests for `optional<T&>` that were commented out like this (albeit those were parts of a greater test), but that was likely 8 years ago...so policy regarding stuff like this is different.

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


More information about the libcxx-commits mailing list