Fixing code-point-length
parent
92d58b1160
commit
db876598ed
|
@ -73,12 +73,14 @@ M: utf8 encode-char
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: code-point-length ( n -- x )
|
: code-point-length ( n -- x )
|
||||||
next-power-of-2 log2 {
|
dup zero? [ drop 1 ] [
|
||||||
{ [ dup 0 7 between? ] [ 1 ] }
|
log2 {
|
||||||
{ [ dup 8 11 between? ] [ 2 ] }
|
{ [ dup 0 6 between? ] [ 1 ] }
|
||||||
{ [ dup 12 16 between? ] [ 3 ] }
|
{ [ dup 7 10 between? ] [ 2 ] }
|
||||||
{ [ dup 17 21 between? ] [ 4 ] }
|
{ [ dup 11 15 between? ] [ 3 ] }
|
||||||
} cond nip ;
|
{ [ dup 16 20 between? ] [ 4 ] }
|
||||||
|
} cond nip
|
||||||
|
] if ;
|
||||||
|
|
||||||
: code-point-offsets ( string -- indices )
|
: code-point-offsets ( string -- indices )
|
||||||
0 [ code-point-length + ] accumulate swap suffix ;
|
0 [ code-point-length + ] accumulate swap suffix ;
|
||||||
|
|
Loading…
Reference in New Issue