base16/32/64/85/91: declare base>ch as fixnum.
parent
c6e14ce3ca
commit
53d404a150
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2008 Doug Coleman, Daniel Ehrenberg.
|
! Copyright (C) 2008 Doug Coleman, Daniel Ehrenberg.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays assocs byte-arrays combinators fry io io.binary
|
USING: arrays assocs byte-arrays combinators fry io io.binary
|
||||||
io.encodings.binary io.streams.byte-array kernel literals math
|
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||||
namespaces sbufs sequences ;
|
literals math namespaces sbufs sequences ;
|
||||||
IN: base64
|
IN: base64
|
||||||
|
|
||||||
ERROR: malformed-base64 ;
|
ERROR: malformed-base64 ;
|
||||||
|
@ -26,7 +26,7 @@ CONSTANT: alphabet $[
|
||||||
|
|
||||||
: base64>ch ( ch -- ch )
|
: base64>ch ( ch -- ch )
|
||||||
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
||||||
[ malformed-base64 ] unless* ; inline
|
[ malformed-base64 ] unless* { fixnum } declare ; inline
|
||||||
|
|
||||||
: (write-lines) ( column byte-array -- column' )
|
: (write-lines) ( column byte-array -- column' )
|
||||||
output-stream get dup '[
|
output-stream get dup '[
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2019 John Benediktsson.
|
! Copyright (C) 2019 John Benediktsson.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: base64.private byte-arrays combinators io
|
USING: base64.private byte-arrays combinators io
|
||||||
io.encodings.binary io.streams.byte-array kernel literals locals
|
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||||
math namespaces sequences ;
|
literals locals math namespaces sequences ;
|
||||||
IN: base16
|
IN: base16
|
||||||
|
|
||||||
ERROR: malformed-base16 ;
|
ERROR: malformed-base16 ;
|
||||||
|
@ -20,7 +20,7 @@ CONSTANT: alphabet $[ "0123456789ABCDEF" >byte-array ]
|
||||||
|
|
||||||
: base16>ch ( ch -- ch )
|
: base16>ch ( ch -- ch )
|
||||||
$[ alphabet alphabet-inverse ] nth
|
$[ alphabet alphabet-inverse ] nth
|
||||||
[ malformed-base16 ] unless* ; inline
|
[ malformed-base16 ] unless* { fixnum } declare ; inline
|
||||||
|
|
||||||
:: (encode-base16) ( stream -- )
|
:: (encode-base16) ( stream -- )
|
||||||
stream stream-read1 [
|
stream stream-read1 [
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2019 John Benediktsson
|
! Copyright (C) 2019 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
USING: base64.private byte-arrays combinators fry io io.binary
|
USING: base64.private byte-arrays combinators fry io io.binary
|
||||||
io.encodings.binary io.streams.byte-array kernel literals math
|
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||||
namespaces sequences ;
|
literals math namespaces sequences ;
|
||||||
IN: base32
|
IN: base32
|
||||||
|
|
||||||
ERROR: malformed-base32 ;
|
ERROR: malformed-base32 ;
|
||||||
|
@ -22,7 +22,7 @@ CONSTANT: alphabet $[ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" >byte-array ]
|
||||||
|
|
||||||
: base32>ch ( ch -- ch )
|
: base32>ch ( ch -- ch )
|
||||||
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
||||||
[ malformed-base32 ] unless* ; inline
|
[ malformed-base32 ] unless* { fixnum } declare ; inline
|
||||||
|
|
||||||
: encode5 ( seq -- byte-array )
|
: encode5 ( seq -- byte-array )
|
||||||
be> { -35 -30 -25 -20 -15 -10 -5 0 } '[
|
be> { -35 -30 -25 -20 -15 -10 -5 0 } '[
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2013 John Benediktsson.
|
! Copyright (C) 2013 John Benediktsson.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: base64.private byte-arrays combinators io io.binary
|
USING: base64.private byte-arrays combinators io io.binary
|
||||||
io.encodings.binary io.streams.byte-array kernel literals math
|
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||||
namespaces sequences ;
|
literals math namespaces sequences ;
|
||||||
IN: base85
|
IN: base85
|
||||||
|
|
||||||
ERROR: malformed-base85 ;
|
ERROR: malformed-base85 ;
|
||||||
|
@ -21,7 +21,7 @@ CONSTANT: alphabet $[
|
||||||
|
|
||||||
: base85>ch ( ch -- ch )
|
: base85>ch ( ch -- ch )
|
||||||
$[ alphabet alphabet-inverse ] nth
|
$[ alphabet alphabet-inverse ] nth
|
||||||
[ malformed-base85 ] unless* ; inline
|
[ malformed-base85 ] unless* { fixnum } declare ; inline
|
||||||
|
|
||||||
: encode4 ( seq -- seq' )
|
: encode4 ( seq -- seq' )
|
||||||
be> 5 [ 85 /mod ch>base85 ] B{ } replicate-as reverse! nip ; inline
|
be> 5 [ 85 /mod ch>base85 ] B{ } replicate-as reverse! nip ; inline
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2019 John Benediktsson.
|
! Copyright (C) 2019 John Benediktsson.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: base64.private byte-arrays kernel literals locals math
|
USING: base64.private byte-arrays kernel kernel.private
|
||||||
sequences ;
|
literals locals math sequences ;
|
||||||
IN: base91
|
IN: base91
|
||||||
|
|
||||||
ERROR: malformed-base91 ;
|
ERROR: malformed-base91 ;
|
||||||
|
@ -20,7 +20,7 @@ CONSTANT: alphabet $[
|
||||||
|
|
||||||
: base91>ch ( ch -- ch )
|
: base91>ch ( ch -- ch )
|
||||||
$[ alphabet alphabet-inverse ] nth
|
$[ alphabet alphabet-inverse ] nth
|
||||||
[ malformed-base91 ] unless* ; inline
|
[ malformed-base91 ] unless* { fixnum } declare ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue