Mercurial > projects > dwt-win
diff 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 |
line wrap: on
line diff
--- 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; }