1 ;; -*- coding: utf-8 -*-
2 #+(or (not sb-unicode
) unicode-lite
) (invoke-restart 'run-tests
::skip-file
)
4 (let ((str (coerce '(#\u0041 #\uff71 #\uff21 #\u3042 #\u6f3e #\u71f9 #\u91ed)
6 (eucjp '(#x41
#x8e
#xb1
#xa3
#xc1
#xa4
#xa2
#xdf
#xa1
#xe0
#xa1
8 (sjis '(#x41
#xb1
#x82
#x60
#x82
#xa0
#xe0
#x40
#xe0
#x9f
#xfb
#xbd
))
9 (file (scratch-file-name)))
10 (dolist (pair (list (list eucjp
:euc-jp
)
11 (list sjis
:shift_jis
)))
12 (destructuring-bind (bytes enc
) pair
13 ;; check if output works
14 (with-open-file (s file
:direction
:output
15 :if-exists
:supersede
:external-format enc
)
17 (with-open-file (s file
:direction
:input
18 :element-type
'(unsigned-byte 8))
20 do
(assert (eql (read-byte s
) c
))))
22 ;; check if input works
23 (with-open-file (s file
:direction
:input
:external-format enc
)
24 (loop for c across str
25 do
(assert (eql (read-char s
) c
))))
27 ;; check if string conversion works
28 (assert (equal (coerce (string-to-octets str
:external-format enc
)
31 (assert (equal (octets-to-string (coerce bytes
32 '(vector (unsigned-byte 8)))