Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
: showbytes ( c-addr u -- )
|
||||
over + swap ?do
|
||||
i c@ 3 .r loop ;
|
||||
|
||||
: test {: xc -- :}
|
||||
xc xemit xc 6 .r xc pad xc!+ pad tuck - ( c-addr u )
|
||||
2dup showbytes drop xc@+ xc <> abort" test failed" drop cr ;
|
||||
|
||||
hex
|
||||
$41 test $f6 test $416 test $20ac test $1d11e test
|
||||
\ can also be written as
|
||||
\ 'A' test 'ö' test 'Ж' test '€' test '𝄞' test
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
-77 Constant UTF-8-err
|
||||
|
||||
$80 Constant max-single-byte
|
||||
|
||||
: u8@+ ( u8addr -- u8addr' u )
|
||||
count dup max-single-byte u< ?EXIT \ special case ASCII
|
||||
dup $C2 u< IF UTF-8-err throw THEN \ malformed character
|
||||
$7F and $40 >r
|
||||
BEGIN dup r@ and WHILE r@ xor
|
||||
6 lshift r> 5 lshift >r >r count
|
||||
dup $C0 and $80 <> IF UTF-8-err throw THEN
|
||||
$3F and r> or
|
||||
REPEAT rdrop ;
|
||||
|
||||
: u8!+ ( u u8addr -- u8addr' )
|
||||
over max-single-byte u< IF tuck c! 1+ EXIT THEN \ special case ASCII
|
||||
>r 0 swap $3F
|
||||
BEGIN 2dup u> WHILE
|
||||
2/ >r dup $3F and $80 or swap 6 rshift r>
|
||||
REPEAT $7F xor 2* or r>
|
||||
BEGIN over $80 u>= WHILE tuck c! 1+ REPEAT nip ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue