[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: %default-port-conversion-strategy and string ports
From: |
Ludovic Courtès |
Subject: |
Re: %default-port-conversion-strategy and string ports |
Date: |
Fri, 01 Jun 2012 18:34:04 +0200 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) |
Hi David,
Ports in Guile can be used to write characters, or bytes, or both. In
particular, every port (including string ports, void ports, etc.) has an
“encoding”, which is actually only used for textual I/O.
Conversely, an R6RS port is either textual or binary, but not both.
IMO, one advantage of mixed text/binary ports is to allow things like this:
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"
Thanks,
Ludo’.
- Re: %default-port-conversion-strategy and string ports, Ludovic Courtès, 2012/06/01
- Re: %default-port-conversion-strategy and string ports, David Kastrup, 2012/06/01
- Re: %default-port-conversion-strategy and string ports,
Ludovic Courtès <=
- Re: %default-port-conversion-strategy and string ports, Mark H Weaver, 2012/06/01
- Re: %default-port-conversion-strategy and string ports, Ludovic Courtès, 2012/06/02
- Re: %default-port-conversion-strategy and string ports, David Kastrup, 2012/06/02
- Re: %default-port-conversion-strategy and string ports, Daniel Krueger, 2012/06/03
- Separate textual/binary ports vs. mixed ports, Ludovic Courtès, 2012/06/03
- Re: Separate textual/binary ports vs. mixed ports, Daniel Krueger, 2012/06/05
- Re: Separate textual/binary ports vs. mixed ports, Noah Lavine, 2012/06/05
- Re: Separate textual/binary ports vs. mixed ports, Ludovic Courtès, 2012/06/05
- Re: Separate textual/binary ports vs. mixed ports, Ludovic Courtès, 2012/06/05