diff --git a/source/utf8/checked.h b/source/utf8/checked.h index 1c1cadd..cc1ec47 100644 --- a/source/utf8/checked.h +++ b/source/utf8/checked.h @@ -109,13 +109,13 @@ namespace utf8 case internal::NOT_ENOUGH_ROOM: throw not_enough_room(); case internal::INVALID_LEAD: - utf8::append (replacement, out); + out = utf8::append (replacement, out); ++start; break; case internal::INCOMPLETE_SEQUENCE: case internal::OVERLONG_SEQUENCE: case internal::INVALID_CODE_POINT: - utf8::append (replacement, out); + out = utf8::append (replacement, out); ++start; // just one replacement mark for the sequence while (start != end && utf8::internal::is_trail(*start)) diff --git a/test_drivers/smoke_test/test.cpp b/test_drivers/smoke_test/test.cpp index 9273da2..7489835 100644 --- a/test_drivers/smoke_test/test.cpp +++ b/test_drivers/smoke_test/test.cpp @@ -153,12 +153,12 @@ int main() //replace_invalid char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z"; - vector replace_invalid_result; - replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), back_inserter(replace_invalid_result), '?'); + vector replace_invalid_result(50); + replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), replace_invalid_result.begin(), '?'); bvalid = is_valid(replace_invalid_result.begin(), replace_invalid_result.end()); assert (bvalid); const char* fixed_invalid_sequence = "a????z"; - assert (std::equal(replace_invalid_result.begin(), replace_invalid_result.end(), fixed_invalid_sequence)); + assert (std::equal(replace_invalid_result.begin(), replace_invalid_result.begin() + sizeof(fixed_invalid_sequence), fixed_invalid_sequence)); // iterator utf8::iterator it(threechars, threechars, threechars + 9);