An implementation of "Standard Compression Scheme for Unicode" by Common Lisp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
API.md
LICENSE
README.md
TODO.org
cl-scsu-test.asd
cl-scsu.asd

README.md

Abstract

Standard Compression Scheme for Unicode の Common Lisp 実装。

cl-scsu is an implementation of Standard Compression Scheme for Unicode by Common Lisp.

License

The MIT License. See LICENSE file.

Loading

Libraries depending on

  • asdf
  • alexandria

Load by quicklisp

Quicklisp

(ql:quickload "cl-scsu")

or, Load manually

(load "cl-scsu.asd")
(asdf:load-system :cl-scsu)

For running tests, do below additionally.

(load "cl-scsu-test.asd")
(asdf:test-system :cl-scsu)

Examples

Makes a test string, estimated 38 bytes long by counting Japanese characters as 2 bytes.

CL-USER> (defvar *test-string* "abcde あいうえお アイウエオ 阿伊宇江於")
*TEST-STRING*

Let's compress it. The result is only 30 bytes long.

CL-USER> (cl-scsu:encode-from-string *test-string*)
#(97 98 99 100 101 32 21 130 132 134 136 138 32 226 228 230 232 234 32
  15 150 63 79 10 91 135 108 95 101 188) ; compressin result
30                                       ; number of result bytes
23                                       ; number of read characters
#<CL-SCSU:SCSU-STATE @ #x10002ed37c2>    ; scsu state object

To restore the original string, decompress the bytes.

CL-USER> (cl-scsu:decode-to-string *)
"abcde あいうえお アイウエオ 阿伊宇江於" ; decompression result
23                                       ; number of result characters
30                                       ; number of read bytes
#<CL-SCSU:SCSU-STATE @ #x10002f469f2>    ; scsu state object

API

see API.md.