comparison dwt/dwthelper/utils.d @ 324:ba58cbca64a1

More unicode checks
author Frank Benoit <benoit@tionex.de>
date Sun, 30 Nov 2008 09:42:03 +0100
parents 7066c4836d65
children 0c891bed575f
comparison
equal deleted inserted replaced
323:7066c4836d65 324:ba58cbca64a1
485 if( ( str[index] & 0x80 ) is 0x00 ) 485 if( ( str[index] & 0x80 ) is 0x00 )
486 { 486 {
487 return index; 487 return index;
488 } 488 }
489 else{ 489 else{
490 int steps = 0;
490 while(( str[index] & 0xC0 ) is 0x80 ){ 491 while(( str[index] & 0xC0 ) is 0x80 ){
491 index--; 492 index--;
493 steps++;
494 if( steps > 3 || index < 0 ){
495 break;
496 }
497 }
498 if((( str[index] & 0xE0 ) is 0xC0) && ( steps <= 1 )){
499 // ok
500 }
501 else if((( str[index] & 0xF0 ) is 0xE0) && ( steps <= 2 )){
502 // ok
503 }
504 else if((( str[index] & 0xF8 ) is 0xF0) && ( steps <= 3 )){
505 // ok
506 }
507 else{
508 tango.text.convert.Utf.onUnicodeError( "invalid utf8 input to toAbsoluteCodePointStartOffset" );
492 } 509 }
493 return index; 510 return index;
494 } 511 }
495 } 512 }
496 int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){ 513 int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){