mirror of
https://github.com/boostorg/detail.git
synced 2025-07-30 04:17:14 +02:00
Fixed length calculation and added a test.
This commit is contained in:
@ -204,7 +204,7 @@ BOOST_UTF8_DECL int utf8_codecvt_facet::do_length(
|
||||
last_octet_count = (get_octet_count(*from_next));
|
||||
++char_count;
|
||||
}
|
||||
return static_cast<int>(from_next-from_end);
|
||||
return static_cast<int>(from_next-from);
|
||||
}
|
||||
|
||||
BOOST_UTF8_DECL unsigned int utf8_codecvt_facet::get_octet_count(
|
||||
|
@ -29,7 +29,7 @@ namespace std{
|
||||
using ::wcslen;
|
||||
#if !defined(UNDER_CE) && !defined(__PGIC__)
|
||||
using ::w_int;
|
||||
#endif
|
||||
#endif
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
@ -251,6 +251,16 @@ test_main(int /* argc */, char * /* argv */[]) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Test length calculation
|
||||
{
|
||||
std::codecvt<wchar_t, char, std::mbstate_t> const& fac = std::use_facet< std::codecvt<wchar_t, char, std::mbstate_t> >(utf8_locale);
|
||||
std::mbstate_t mbs = std::mbstate_t();
|
||||
const int utf8_len = sizeof(td::utf8_encoding) / sizeof(*td::utf8_encoding);
|
||||
int res = fac.length(mbs, reinterpret_cast< const char* >(td::utf8_encoding), reinterpret_cast< const char* >(td::utf8_encoding + utf8_len), ~static_cast< std::size_t >(0u));
|
||||
BOOST_TEST_EQ(utf8_len, res);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user