@@ -425,22 +425,22 @@ char32 UnicodeText::const_iterator::operator*() const {
425
425
// for speed, we do the calculation ourselves.)
426
426
427
427
// Convert from UTF-8
428
- int byte1 = it_[0 ];
428
+ unsigned char byte1 = it_[0 ];
429
429
if (byte1 < 0x80 )
430
430
return byte1;
431
431
432
- int byte2 = it_[1 ];
432
+ unsigned char byte2 = it_[1 ];
433
433
if (byte1 < 0xE0 )
434
434
return ((byte1 & 0x1F ) << 6 )
435
435
| (byte2 & 0x3F );
436
436
437
- int byte3 = it_[2 ];
437
+ unsigned char byte3 = it_[2 ];
438
438
if (byte1 < 0xF0 )
439
439
return ((byte1 & 0x0F ) << 12 )
440
440
| ((byte2 & 0x3F ) << 6 )
441
441
| (byte3 & 0x3F );
442
442
443
- int byte4 = it_[3 ];
443
+ unsigned char byte4 = it_[3 ];
444
444
return ((byte1 & 0x07 ) << 18 )
445
445
| ((byte2 & 0x3F ) << 12 )
446
446
| ((byte3 & 0x3F ) << 6 )
@@ -458,9 +458,9 @@ UnicodeText::const_iterator& UnicodeText::const_iterator::operator--() {
458
458
}
459
459
460
460
int UnicodeText::const_iterator::get_utf8 (char * utf8_output) const {
461
- utf8_output[0 ] = it_[0 ]; if (it_[0 ] < 0x80 ) return 1 ;
462
- utf8_output[1 ] = it_[1 ]; if (it_[0 ] < 0xE0 ) return 2 ;
463
- utf8_output[2 ] = it_[2 ]; if (it_[0 ] < 0xF0 ) return 3 ;
461
+ utf8_output[0 ] = it_[0 ]; if (( it_[0 ] & 0xff ) < 0x80 ) return 1 ;
462
+ utf8_output[1 ] = it_[1 ]; if (( it_[0 ] & 0xff ) < 0xE0 ) return 2 ;
463
+ utf8_output[2 ] = it_[2 ]; if (( it_[0 ] & 0xff ) < 0xF0 ) return 3 ;
464
464
utf8_output[3 ] = it_[3 ];
465
465
return 4 ;
466
466
}
@@ -470,11 +470,11 @@ string UnicodeText::const_iterator::get_utf8_string() const {
470
470
}
471
471
472
472
int UnicodeText::const_iterator::utf8_length () const {
473
- if (it_[0 ] < 0x80 ) {
473
+ if (( it_[0 ] & 0xff ) < 0x80 ) {
474
474
return 1 ;
475
- } else if (it_[0 ] < 0xE0 ) {
475
+ } else if (( it_[0 ] & 0xff ) < 0xE0 ) {
476
476
return 2 ;
477
- } else if (it_[0 ] < 0xF0 ) {
477
+ } else if (( it_[0 ] & 0xff ) < 0xF0 ) {
478
478
return 3 ;
479
479
} else {
480
480
return 4 ;
0 commit comments