Skip to content

[libc++][print] Renames __use_unicode. #76290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libcxx/include/ostream
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ template <class... _Args>
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_HIDE_FROM_ABI void
print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
# ifndef _LIBCPP_HAS_NO_UNICODE
if constexpr (__print::__use_unicode)
if constexpr (__print::__use_unicode_execution_charset)
std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);
else
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
Expand All @@ -1153,7 +1153,7 @@ println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
// Note the wording in the Standard is inefficient. The output of
// std::format is a std::string which is then copied. This solution
// just appends a newline at the end of the output.
if constexpr (__print::__use_unicode)
if constexpr (__print::__use_unicode_execution_charset)
std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);
else
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/print
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ namespace __print {
//

# ifdef _LIBCPP_HAS_NO_UNICODE
inline constexpr bool __use_unicode = false;
inline constexpr bool __use_unicode_execution_charset = false;
# elif defined(_MSVC_EXECUTION_CHARACTER_SET)
// This is the same test MSVC STL uses in their implementation of <print>
// See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
inline constexpr bool __use_unicode = _MSVC_EXECUTION_CHARACTER_SET == 65001;
inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTER_SET == 65001;
# else
inline constexpr bool __use_unicode = true;
inline constexpr bool __use_unicode_execution_charset = true;
# endif

_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal(FILE* __stream) {
Expand Down Expand Up @@ -329,7 +329,7 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {
# ifndef _LIBCPP_HAS_NO_UNICODE
if constexpr (__print::__use_unicode)
if constexpr (__print::__use_unicode_execution_charset)
__print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
else
__print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
Expand All @@ -349,7 +349,7 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt
// Note the wording in the Standard is inefficient. The output of
// std::format is a std::string which is then copied. This solution
// just appends a newline at the end of the output.
if constexpr (__print::__use_unicode)
if constexpr (__print::__use_unicode_execution_charset)
__print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
else
__print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
Expand Down