Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,56 @@
( ( VLQ
= b07 b8 vlq
. 0:?b8
& :?vlq
& whl
' ( !arg:>0
& mod$(!arg.128):?b07
& (chr$(!b8+!b07)|) !vlq:?vlq
& 128:?b8
& div$(!arg.128):?arg
)
& str$!vlq
)
& ( NUM
= c num d
. 0:?num:?d
& whl
' ( @(!arg:%@?c ?arg)
& asc$!c:?c:~<128
& 128*(!c+-128+!num):?num
& 1+!d:?d
)
& (!c:<128&!c+!num:?num|)
& !num
)
& ( printVLQ
= c h
. :?h
& whl
' ( @(!arg:%@?c ?arg)
& d2x$(asc$!c):?x
& !h (@(!x:? [1)&0|) !x
: ?h
)
& ( asc$!c:~<128&!h 00:?h
|
)
& out$("VLQ :" str$!h)
)
& ( test
= vlq num
. out$("input:" !arg)
& VLQ$(x2d$!arg):?vlq
& printVLQ$!vlq
& NUM$!vlq:?num
& out$("back :" d2x$!num \n)
)
& test$200000
& test$1fffff
& test$00
& test$7f
& test$80
& test$81
& test$82
& test$894E410E0A
);

View file

@ -49,7 +49,7 @@ struct VLQ {
return res;
}
string toString() const /*pure nothrow*/ {
string toString() const pure /*nothrow*/ {
return format("(%(%02X:%))", this.toVLQ);
}
}

View file

@ -0,0 +1,22 @@
@(do
;; show the utf8 bytes from byte stream as hex
(defun put-utf8 (str : stream)
(set stream (or stream *stdout*))
(for ((s (make-string-byte-input-stream str)) byte)
((set byte (get-byte s)))
((format stream "\\x~,02x" byte))))
;; print
(put-utf8 (tostring 0))
(put-line "")
(put-utf8 (tostring 42))
(put-line "")
(put-utf8 (tostring #x200000))
(put-line "")
(put-utf8 (tostring #x1fffff))
(put-line "")
;; print to string and recover
(format t "~a\n" (read (tostring #x200000)))
(format t "~a\n" (read (tostring #x1f0000))))