Fix for bug ID: 3576827 - replace_invalid() only works with back_inserter

git-svn-id: http://svn.code.sf.net/p/utfcpp/code@136 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
ntrifunovic 2013-02-09 23:33:27 +00:00
parent 7767eb67e8
commit 129a2f4508
2 changed files with 5 additions and 5 deletions

View file

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

View file

@ -153,12 +153,12 @@ int main()
//replace_invalid
char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z";
vector<char> replace_invalid_result;
replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), back_inserter(replace_invalid_result), '?');
vector<char> 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<const char*> it(threechars, threechars, threechars + 9);