|
25 | 25 |
|
26 | 26 | // Priority order: |
27 | 27 | // 1.) Use fmt::print if available (this will offer the most possible features, e.g. colored output, string formatting within script code, etc...) |
28 | | -// 2.) Use std::vprint_unicode if available. |
29 | | -// 3.) Use std::cout + std::format |
| 28 | +// 2.) Use C++23 std::print if available. |
| 29 | +// 3.) Use C++20 std::cout + std::format |
30 | 30 | #if __has_include( "fmt/format.h" ) && !defined( TEASCRIPT_DISABLE_FMTLIB ) |
31 | 31 | # define TEASCRIPT_FMTFORMAT 1 |
32 | 32 | # ifndef TEASCRIPT_DISABLE_FMT_HEADER_ONLY |
|
40 | 40 | # endif |
41 | 41 | #elif __has_include( <format> ) |
42 | 42 | # include <format> |
43 | | -# if defined( __cpp_lib_format ) && __cpp_lib_format > 202110L && __cplusplus > 202002L && !defined( TEASCRIPT_DISABLE_STDFORMAT_23 ) |
| 43 | +// for Visual Studio we not only need C++23 but also at least VS 2022 17.13 with C++23 preview for have a working std::print with UTF-8 support. |
| 44 | +# if defined( __cpp_lib_format ) && __cpp_lib_format > 202110L && __cplusplus > 202002L && !defined( TEASCRIPT_DISABLE_STDFORMAT_23 ) && (!defined(_MSC_VER) || _MSC_VER >= 1943) |
44 | 45 | # define TEASCRIPT_STDFORMAT_23 1 |
45 | 46 | # include <print> |
46 | 47 | # else |
|
60 | 61 | # define TEASCRIPT_PRINT( ... ) fmt::print( __VA_ARGS__ ) |
61 | 62 | # define TEASCRIPT_ERROR( ... ) fmt::print( stderr, __VA_ARGS__ ) |
62 | 63 | #elif TEASCRIPT_STDFORMAT_23 |
63 | | -# define TEASCRIPT_PRINT( ... ) std::vprint_unicode( __VA_ARGS__ ) |
64 | | -# define TEASCRIPT_ERROR( ... ) std::vprint_unicode( stderr, __VA_ARGS__ ) |
| 64 | +# define TEASCRIPT_PRINT( ... ) std::print( __VA_ARGS__ ) |
| 65 | +# define TEASCRIPT_ERROR( ... ) std::print( stderr, __VA_ARGS__ ) |
65 | 66 | #elif TEASCRIPT_STDFORMAT_20 |
66 | 67 | // NOTE: On Windows you must most likely hook up the streambuf of std::cout/std::cerr for support full UTF-8 |
67 | 68 | # define TEASCRIPT_PRINT( ... ) std::cout << std::format( __VA_ARGS__ ) |
|
0 commit comments