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);