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:
parent
7767eb67e8
commit
129a2f4508
2 changed files with 5 additions and 5 deletions
|
@ -109,13 +109,13 @@ namespace utf8
|
||||||
case internal::NOT_ENOUGH_ROOM:
|
case internal::NOT_ENOUGH_ROOM:
|
||||||
throw not_enough_room();
|
throw not_enough_room();
|
||||||
case internal::INVALID_LEAD:
|
case internal::INVALID_LEAD:
|
||||||
utf8::append (replacement, out);
|
out = utf8::append (replacement, out);
|
||||||
++start;
|
++start;
|
||||||
break;
|
break;
|
||||||
case internal::INCOMPLETE_SEQUENCE:
|
case internal::INCOMPLETE_SEQUENCE:
|
||||||
case internal::OVERLONG_SEQUENCE:
|
case internal::OVERLONG_SEQUENCE:
|
||||||
case internal::INVALID_CODE_POINT:
|
case internal::INVALID_CODE_POINT:
|
||||||
utf8::append (replacement, out);
|
out = utf8::append (replacement, out);
|
||||||
++start;
|
++start;
|
||||||
// just one replacement mark for the sequence
|
// just one replacement mark for the sequence
|
||||||
while (start != end && utf8::internal::is_trail(*start))
|
while (start != end && utf8::internal::is_trail(*start))
|
||||||
|
|
|
@ -153,12 +153,12 @@ int main()
|
||||||
|
|
||||||
//replace_invalid
|
//replace_invalid
|
||||||
char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z";
|
char invalid_sequence[] = "a\x80\xe0\xa0\xc0\xaf\xed\xa0\x80z";
|
||||||
vector<char> replace_invalid_result;
|
vector<char> replace_invalid_result(50);
|
||||||
replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), back_inserter(replace_invalid_result), '?');
|
replace_invalid (invalid_sequence, invalid_sequence + sizeof(invalid_sequence), replace_invalid_result.begin(), '?');
|
||||||
bvalid = is_valid(replace_invalid_result.begin(), replace_invalid_result.end());
|
bvalid = is_valid(replace_invalid_result.begin(), replace_invalid_result.end());
|
||||||
assert (bvalid);
|
assert (bvalid);
|
||||||
const char* fixed_invalid_sequence = "a????z";
|
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
|
// iterator
|
||||||
utf8::iterator<const char*> it(threechars, threechars, threechars + 9);
|
utf8::iterator<const char*> it(threechars, threechars, threechars + 9);
|
||||||
|
|
Loading…
Reference in a new issue