1
0

fix: change the behavior of printf in string op.

- add compiler hint for checking the arguments of printf.
- change the return value of printf. from std::expected to normal value. use C++ exception to indicate error.
	* the error of printf usually caused by programmer. so it can be found when testing program.
	* so i use std::logic_error to indicate this and programmer should fix this before releasing program.
- change the use of encoding convertion. for those cases that convertion must be safe, we unwrap it directly.
This commit is contained in:
2025-09-22 22:14:36 +08:00
parent 45e4031b5c
commit c85830902b
22 changed files with 240 additions and 164 deletions

View File

@ -468,11 +468,8 @@ namespace yycc::carton::wcwidth {
}
Result<size_t> wcswidth(const std::u8string_view& rhs) {
// Cast encoding
auto u32str = ENC::to_utf32(rhs);
if (!u32str.has_value()) return std::unexpected(Error::BadEncoding);
// Call underlying function
return wcswidth(u32str.value());
// Cast encoding and call underlying function
return wcswidth(ENC::to_utf32(rhs).value());
}
} // namespace yycc::carton::wcwidth