# HG changeset patch # User Frank Benoit # Date 1228034523 -3600 # Node ID ba58cbca64a157375abef807253f3b9c30f5a449 # Parent 7066c4836d65445bcb68005729c5f92ea8d62207 More unicode checks diff -r 7066c4836d65 -r ba58cbca64a1 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Sun Nov 30 09:25:27 2008 +0100 +++ b/dwt/dwthelper/utils.d Sun Nov 30 09:42:03 2008 +0100 @@ -487,8 +487,25 @@ return index; } else{ + int steps = 0; while(( str[index] & 0xC0 ) is 0x80 ){ index--; + steps++; + if( steps > 3 || index < 0 ){ + break; + } + } + if((( str[index] & 0xE0 ) is 0xC0) && ( steps <= 1 )){ + // ok + } + else if((( str[index] & 0xF0 ) is 0xE0) && ( steps <= 2 )){ + // ok + } + else if((( str[index] & 0xF8 ) is 0xF0) && ( steps <= 3 )){ + // ok + } + else{ + tango.text.convert.Utf.onUnicodeError( "invalid utf8 input to toAbsoluteCodePointStartOffset" ); } return index; }