From e62493a678801baf2415b21baea03bc06c876c93 Mon Sep 17 00:00:00 2001 From: Aleksandr Orefkov Date: Wed, 11 Feb 2026 11:24:57 +0300 Subject: [PATCH] Fix error converting to double char8_t --- include/simstr/sstring.h | 2 +- tests/test_str.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/simstr/sstring.h b/include/simstr/sstring.h index 5cd7398..613f859 100644 --- a/include/simstr/sstring.h +++ b/include/simstr/sstring.h @@ -306,7 +306,7 @@ public: #ifdef __linux__ if constexpr(sizeof(K) == 1) { double d{}; - if (std::from_chars(ptr, ptr + len, d).ec == std::errc{}) { + if (std::from_chars((const u8s*)ptr, (const u8s*)ptr + len, d).ec == std::errc{}) { return d; } return {}; diff --git a/tests/test_str.cpp b/tests/test_str.cpp index df50267..c0adef7 100644 --- a/tests/test_str.cpp +++ b/tests/test_str.cpp @@ -484,6 +484,8 @@ TEST(SimStr, ToInt) { TEST(SimStr, to_double) { EXPECT_EQ(ssa{" 123"}.to_double(), 123.0); EXPECT_EQ(ssa{" 123.1"}.to_double(), 123.1); + EXPECT_EQ(ssb{u8" 123"}.to_double(), 123.0); + EXPECT_EQ(ssb{u8" 123.1"}.to_double(), 123.1); EXPECT_EQ(ssu{u" 123.13434"}.to_double(), 123.13434); EXPECT_EQ(ssuu{U" 123.13434"}.to_double(), 123.13434); EXPECT_EQ(ssw{L" 123.13434"}.to_double(), 123.13434);