refactor: Unicode symbols description reworked based on the latest SG16 recommendations

This commit is contained in:
Mateusz Pusz
2024-10-28 16:03:09 +01:00
parent c72d801ef8
commit 4651c61be4
3 changed files with 18 additions and 17 deletions

View File

@@ -196,7 +196,7 @@ For some units, a magnitude might also be irrational. The best example here is a
is defined using a floating-point magnitude having a factor of the number π (Pi):
```cpp
inline constexpr struct pi final : mag_constant<symbol_text{u8"\u03c0", "pi"}, std::numbers::pi_v<long double>> {} pi;
inline constexpr struct pi final : mag_constant<symbol_text{u8"π", "pi"}, std::numbers::pi_v<long double>> {
inline constexpr auto π = pi;
```

View File

@@ -43,27 +43,27 @@ template<std::intmax_t Value>
constexpr basic_fixed_string superscript_number = u8"";
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<0> = u8"\u2070";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<0> = u8"" /* U+2070 SUPERSCRIPT ZERO */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<1> = u8"\u00b9";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<1> = u8"¹" /* U+00B9 SUPERSCRIPT ONE */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<2> = u8"\u00b2";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<2> = u8"²" /* U+00B2 SUPERSCRIPT TWO */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<3> = u8"\u00b3";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<3> = u8"³" /* U+00B3 SUPERSCRIPT THREE */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<4> = u8"\u2074";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<4> = u8"" /* U+2074 SUPERSCRIPT FOUR */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<5> = u8"\u2075";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<5> = u8"" /* U+2075 SUPERSCRIPT FIVE */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<6> = u8"\u2076";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<6> = u8"" /* U+2076 SUPERSCRIPT SIX */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<7> = u8"\u2077";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<7> = u8"" /* U+2077 SUPERSCRIPT SEVEN */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<8> = u8"\u2078";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<8> = u8"" /* U+2078 SUPERSCRIPT EIGHT */;
template<>
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<9> = u8"\u2079";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<9> = u8"" /* U+2079 SUPERSCRIPT NINE */;
inline constexpr symbol_text superscript_minus(u8"\u207b", "-");
inline constexpr symbol_text superscript_minus(u8"" /* U+207B SUPERSCRIPT MINUS */, "-");
inline constexpr symbol_text superscript_prefix(u8"", "^");

View File

@@ -326,7 +326,7 @@ constexpr Out print_separator(Out out, const unit_symbol_formatting& fmt)
if (fmt.encoding != text_encoding::utf8)
MP_UNITS_THROW(
std::invalid_argument("'unit_symbol_separator::half_high_dot' can be only used with 'text_encoding::utf8'"));
const std::string_view dot = "\u22C5";
const std::string_view dot = "" /* U+22C5 DOT OPERATOR */;
out = detail::copy(dot.begin(), dot.end(), out);
} else {
*out++ = ' ';
@@ -406,7 +406,7 @@ constexpr Out magnitude_symbol_impl(Out out, const unit_symbol_formatting& fmt)
if constexpr (Exp10 != 0) {
if (numerator || denominator) {
constexpr auto mag_multiplier = symbol_text(u8" \u00D7 ", " x ");
constexpr auto mag_multiplier = symbol_text(u8" × " /* U+00D7 MULTIPLICATION SIGN */, " x ");
out = copy_symbol<CharT>(mag_multiplier, fmt.encoding, negative_power, out);
}
constexpr auto exp = symbol_text("10") + detail::superscript<Exp10>();
@@ -703,13 +703,14 @@ constexpr Magnitude auto mag_power = _pow<Num, Den>(mag<Base>);
* @brief A convenient Magnitude constant for pi, which we can manipulate like a regular number.
*/
#if defined MP_UNITS_COMP_CLANG || MP_UNITS_COMP_CLANG < 18
inline constexpr struct pi final : mag_constant<symbol_text{u8"\u03c0", "pi"}> {
inline constexpr struct pi final : mag_constant<symbol_text{u8"π" /* U+03C0 GREEK SMALL LETTER PI */, "pi"}> {
static constexpr auto _value_ = std::numbers::pi_v<long double>;
#else
inline constexpr struct pi final : mag_constant<symbol_text{u8"\u03c0", "pi"}, std::numbers::pi_v<long double>> {
inline constexpr struct pi final :
mag_constant<symbol_text{u8"π" /* U+03C0 GREEK SMALL LETTER PI */, "pi"}, std::numbers::pi_v<long double>> {
#endif
} pi;
inline constexpr auto π = pi;
inline constexpr auto π /* U+03C0 GREEK SMALL LETTER PI */ = pi;
[[deprecated("Use `mag<pi>` instead")]] inline constexpr Magnitude auto mag_pi = mag<pi>;