Skip to content

Commit ffc3ac4

Browse files
committed
is_legal_utf8
1 parent a1db99a commit ffc3ac4

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

include/jsoncons/utility/unicode_traits.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ namespace unicode_traits {
394394
}
395395
conv_errc result = conv_errc();
396396

397-
unsigned short extra_bytes_to_read = trailing_bytes_for_utf8[*first];
397+
uint16_t extra_bytes_to_read = trailing_bytes_for_utf8[*first];
398398
if (extra_bytes_to_read >= last - first)
399399
{
400400
result = conv_errc::source_exhausted;
@@ -566,7 +566,6 @@ namespace unicode_traits {
566566
const uint8_t* last = data + length;
567567

568568
conv_errc result = conv_errc();
569-
//const CharT* last = data + length;
570569
while (data != last)
571570
{
572571
std::size_t len = trailing_bytes_for_utf8[*data] + 1;
@@ -606,10 +605,9 @@ namespace unicode_traits {
606605

607606
conv_errc result = conv_errc();
608607

609-
//const CharT* last = data + length;
610608
while (data != last)
611609
{
612-
unsigned short extra_bytes_to_read = trailing_bytes_for_utf8[*data];
610+
uint16_t extra_bytes_to_read = trailing_bytes_for_utf8[*data];
613611
if (extra_bytes_to_read >= last - data)
614612
{
615613
result = conv_errc::source_exhausted;
@@ -686,11 +684,10 @@ namespace unicode_traits {
686684

687685
conv_errc result = conv_errc();
688686

689-
const CharT* last = data + length;
690687
while (data < last)
691688
{
692689
uint32_t ch = 0;
693-
unsigned short extra_bytes_to_read = trailing_bytes_for_utf8[*data];
690+
uint16_t extra_bytes_to_read = trailing_bytes_for_utf8[*data];
694691
if (extra_bytes_to_read >= last - data)
695692
{
696693
result = conv_errc::source_exhausted;
@@ -771,7 +768,7 @@ namespace unicode_traits {
771768

772769
const CharT* last = data + length;
773770
while (data < last) {
774-
unsigned short bytes_to_write = 0;
771+
uint16_t bytes_to_write = 0;
775772
static constexpr uint32_t byteMask = 0xBF;
776773
static constexpr uint32_t byteMark = 0x80;
777774
uint32_t ch = *data++;
@@ -982,7 +979,7 @@ namespace unicode_traits {
982979
const CharT* last = data + length;
983980
while (data < last)
984981
{
985-
unsigned short bytes_to_write = 0;
982+
uint16_t bytes_to_write = 0;
986983
static constexpr uint32_t byteMask = 0xBF;
987984
static constexpr uint32_t byteMark = 0x80;
988985
uint32_t ch = *data++;

0 commit comments

Comments
 (0)