Conversation
3 tasks
pauldreik
reviewed
Jan 12, 2026
| char output[2]; | ||
| size_t written = simdutf::convert_utf16_to_utf8_safe( | ||
| input, 2, output, 2); | ||
| ASSERT_EQUAL(written, 2); |
Collaborator
There was a problem hiding this comment.
shouldn't this verify written<=2 ?
Member
Author
There was a problem hiding this comment.
@pauldreik Hmmm... The first character in the input is é which should be converted to TWO bytes in UTF-8. No?
Collaborator
There was a problem hiding this comment.
Yes, but I was thinking we are just verifying the promise of not writing past the output length.
Member
Author
There was a problem hiding this comment.
I don't mind. Changing it.
Collaborator
|
I made a constexpr test for this, which also catches it: namespace {
template <auto input, std::size_t buflen>
constexpr auto convert_insufficient_buf() {
using namespace simdutf::tests::helpers;
constexpr auto Noutput = simdutf::utf8_length_from_utf16(input);
CTString<char8_t, buflen> output{};
const auto ret = simdutf::convert_utf16_to_utf8_safe(input, output);
if (ret == 0) {
throw "failed conversion";
}
return output;
}
} // namespace
TEST(compile_time_check_of_issue_911) {
using namespace simdutf::tests::helpers;
constexpr auto input = u"\u00E9A"_utf16;
constexpr auto expected = u8"\u00E9A"_utf8;
constexpr auto actual = convert_insufficient_buf<input, 2>();
constexpr auto N = std::min(actual.size(), expected.size());
static_assert(expected.shrink<N>() == actual.shrink<N>());
} |
Member
Author
Adding it. |
Member
Author
|
@pauldreik Have another look. |
pauldreik
approved these changes
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #911