Hi Mark, Mark H Weaver skribis: > Okay, now I understand. The problem is that internally, string ports > are implemented by converting the string into a stream of bytes in the > string port's encoding, and then the string port reads those bytes. Exactly. [...] > Conceptually, a string port is a textual port, not a binary port. But not in Guile, where there’s no distinction between textual and binary ports. One can write code like: scheme@(guile-user)> (define (string->utf16 s) (let ((p (with-fluids ((%default-port-encoding "UTF-16BE")) (open-input-string s)))) (get-bytevector-all p))) scheme@(guile-user)> (string->utf16 "hello") $4 = #vu8(0 104 0 101 0 108 0 108 0 111) scheme@(guile-user)> (use-modules(rnrs bytevectors)) scheme@(guile-user)> (utf16->string $4) $5 = "hello" > You should be able to hand it an arbitrary string and read those > characters from it, as described in SRFI-6, without setting > Guile-specific fluid variables. Similarly, you should be able to > write arbitrary characters to a string-output-port. The SRFI-6 issue could be addressed with: