fixed a big in string->utf16 and string->utf32 that I introduced in
the last commit.
This commit is contained in:
parent
0da61d51cb
commit
c0978044a5
|
@ -140,7 +140,8 @@
|
||||||
fxior fxand fxsra fxsll
|
fxior fxand fxsra fxsll
|
||||||
integer->char char->integer
|
integer->char char->integer
|
||||||
string-ref string-set! string-length
|
string-ref string-set! string-length
|
||||||
bytevector-u8-ref bytevector-u8-set!)
|
bytevector-u8-ref bytevector-u8-set!
|
||||||
|
bytevector-u16-ref)
|
||||||
(import
|
(import
|
||||||
(rename (ikarus system $strings)
|
(rename (ikarus system $strings)
|
||||||
($string-length string-length)
|
($string-length string-length)
|
||||||
|
@ -163,7 +164,16 @@
|
||||||
($fx> fx>)
|
($fx> fx>)
|
||||||
($fx>= fx>=)
|
($fx>= fx>=)
|
||||||
($fx<= fx<=)
|
($fx<= fx<=)
|
||||||
($fx= fx=))))
|
($fx= fx=)))
|
||||||
|
(define (bytevector-u16-ref x i endianness)
|
||||||
|
(case endianness
|
||||||
|
[(little)
|
||||||
|
(fxlogor (bytevector-u8-ref x i)
|
||||||
|
(fxsll (bytevector-u8-ref x (fx+ i 1)) 8))]
|
||||||
|
[else
|
||||||
|
(fxlogor (bytevector-u8-ref x (fx+ i 1))
|
||||||
|
(fxsll (bytevector-u8-ref x i) 8))])))
|
||||||
|
|
||||||
|
|
||||||
(define (port? x)
|
(define (port? x)
|
||||||
(import (only (ikarus) port?))
|
(import (only (ikarus) port?))
|
||||||
|
|
|
@ -410,7 +410,7 @@
|
||||||
[(str)
|
[(str)
|
||||||
(unless (string? str)
|
(unless (string? str)
|
||||||
(die 'string->utf16 "not a string" str))
|
(die 'string->utf16 "not a string" str))
|
||||||
($string->utf16 str (native-endianness))]
|
($string->utf16 str 'big)]
|
||||||
[(str endianness)
|
[(str endianness)
|
||||||
(unless (string? str)
|
(unless (string? str)
|
||||||
(die 'string->utf16 "not a string" str))
|
(die 'string->utf16 "not a string" str))
|
||||||
|
@ -431,20 +431,20 @@
|
||||||
(cond
|
(cond
|
||||||
[(or (fx< w1 #xD800) (fx> w1 #xDFFF))
|
[(or (fx< w1 #xD800) (fx> w1 #xDFFF))
|
||||||
(count-size bv endianness (+ i 2) len (+ n 1))]
|
(count-size bv endianness (+ i 2) len (+ n 1))]
|
||||||
[(not (fx<= #xD800 w1 #xDBFF)) ;;; die sequence
|
[(not (fx<= #xD800 w1 #xDBFF)) ;;; error sequence
|
||||||
(count-size bv endianness (+ i 2) len (+ n 1))]
|
(count-size bv endianness (+ i 2) len (+ n 1))]
|
||||||
[(<= (+ i 4) (bytevector-length bv))
|
[(<= (+ i 4) (bytevector-length bv))
|
||||||
(let ([w2 (bytevector-u16-ref bv (+ i 2) endianness)])
|
(let ([w2 (bytevector-u16-ref bv (+ i 2) endianness)])
|
||||||
(cond
|
(cond
|
||||||
[(not (<= #xDC00 w2 #xDFFF))
|
[(not (<= #xDC00 w2 #xDFFF))
|
||||||
;;; do we skip w2 also?
|
;;; do we skip w2 also?
|
||||||
;;; I won't. Just w1 is an die
|
;;; I won't. Just w1 is an error
|
||||||
(count-size bv endianness (+ i 2) len (+ n 1))]
|
(count-size bv endianness (+ i 2) len (+ n 1))]
|
||||||
[else
|
[else
|
||||||
;;; 4-byte sequence is ok
|
;;; 4-byte sequence is ok
|
||||||
(count-size bv endianness (+ i 4) len (+ n 1))]))]
|
(count-size bv endianness (+ i 4) len (+ n 1))]))]
|
||||||
[else
|
[else
|
||||||
;;; die again
|
;;; error again
|
||||||
(count-size bv endianness (+ i 2) len (+ n 1))]))]))
|
(count-size bv endianness (+ i 2) len (+ n 1))]))]))
|
||||||
(define (fill bv endianness str i len n)
|
(define (fill bv endianness str i len n)
|
||||||
(cond
|
(cond
|
||||||
|
@ -531,7 +531,7 @@
|
||||||
[(str)
|
[(str)
|
||||||
(unless (string? str)
|
(unless (string? str)
|
||||||
(die who "not a string" str))
|
(die who "not a string" str))
|
||||||
($string->utf32 str (native-endianness))]
|
($string->utf32 str 'big)]
|
||||||
[(str endianness)
|
[(str endianness)
|
||||||
(unless (string? str)
|
(unless (string? str)
|
||||||
(die who "not a string" str))
|
(die who "not a string" str))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1637
|
1638
|
||||||
|
|
Loading…
Reference in New Issue