* bug#14109: No code for 'bytevector->string' and 'string->bytevector'
@ 2013-04-01 3:12 Nikita Karetnikov
2013-04-01 11:46 ` Ian Price
0 siblings, 1 reply; 3+ messages in thread
From: Nikita Karetnikov @ 2013-04-01 3:12 UTC (permalink / raw)
To: 14109
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
The mentioned functions are documented [1]. However, I'll get the
"Unbound variable" error if I try to import them:
scheme@(guile-user)> ,use (rnrs io ports)
scheme@(guile-user)> string->bytevector
;;; <unknown-location>: warning: possibly unbound variable `string->bytevector'
ERROR: In procedure #<procedure 8ab8bc0 ()>:
ERROR: In procedure module-lookup: Unbound variable: string->bytevector
(I haven't found them via 'grep' too.)
I'm using Guile 2.0.7.
[1] https://gnu.org/software/guile/manual/guile.html#R6RS-Transcoders
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#14109: No code for 'bytevector->string' and 'string->bytevector'
2013-04-01 3:12 bug#14109: No code for 'bytevector->string' and 'string->bytevector' Nikita Karetnikov
@ 2013-04-01 11:46 ` Ian Price
2013-04-01 16:38 ` Mark H Weaver
0 siblings, 1 reply; 3+ messages in thread
From: Ian Price @ 2013-04-01 11:46 UTC (permalink / raw)
To: Nikita Karetnikov; +Cc: 14109
Nikita Karetnikov <nikita@karetnikov.org> writes:
> The mentioned functions are documented [1]. However, I'll get the
> "Unbound variable" error if I try to import them:
>
> scheme@(guile-user)> ,use (rnrs io ports)
> scheme@(guile-user)> string->bytevector
> ;;; <unknown-location>: warning: possibly unbound variable `string->bytevector'
> ERROR: In procedure #<procedure 8ab8bc0 ()>:
> ERROR: In procedure module-lookup: Unbound variable: string->bytevector
Even if they were available, it wouldn't do you much good, because the
general transcoder functionality on ports isn't implemented.
e.g.
scheme@(guile−user)> (open-bytevector-input-port
(string->utf8 "foobarbaz")
(make-transcoder (utf-8-codec)))
GNU Guile: warning: transcoders not implemented
$5 = #<input: r6rs−bytevector−input−port ae46b40>
Maybe we could stub these, since they are mentioned in the info file[0],
and warn about them not being implemented like we do e.g. with
open-bytevector-input-port.
For the moment, the (rnrs bytevectors) module has string->utf8,
string->utf16, and string->utf32 which are implemented. Though, this
doesn't let you specify eol-style or handling-mode.
0. This documentation is lifted straight from the R6RS (modulo
formatting).
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#14109: No code for 'bytevector->string' and 'string->bytevector'
2013-04-01 11:46 ` Ian Price
@ 2013-04-01 16:38 ` Mark H Weaver
0 siblings, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2013-04-01 16:38 UTC (permalink / raw)
To: Ian Price; +Cc: 14109
Ian Price <ianprice90@googlemail.com> writes:
> Nikita Karetnikov <nikita@karetnikov.org> writes:
>
>> The mentioned functions are documented [1]. However, I'll get the
>> "Unbound variable" error if I try to import them:
>>
>> scheme@(guile-user)> ,use (rnrs io ports)
>> scheme@(guile-user)> string->bytevector
>> ;;; <unknown-location>: warning: possibly unbound variable `string->bytevector'
>> ERROR: In procedure #<procedure 8ab8bc0 ()>:
>> ERROR: In procedure module-lookup: Unbound variable: string->bytevector
>
> Even if they were available, it wouldn't do you much good, because the
> general transcoder functionality on ports isn't implemented.
Indeed, it would be good to implement this at some point.
> For the moment, the (rnrs bytevectors) module has string->utf8,
> string->utf16, and string->utf32 which are implemented. Though, this
> doesn't let you specify eol-style or handling-mode.
There's also Andy's shiny new (ice-9 iconv) module, which provides more
general iconv functionality and will make its debut in 2.0.8. It
contains 'string->bytevector' and 'bytevector->string', though beware
that they're not the same as the R6RS procedures, despite their names.
These are documented in section 6.6.5.13 of the manual in stable-2.0,
but were not in the index due to some broken texinfo markup which I just
fixed.
Mark
-- Scheme Procedure: string->bytevector string encoding
[conversion-strategy]
Encode STRING as a sequence of bytes.
The string will be encoded in the character set specified by the
ENCODING string. If the string has characters that cannot be
represented in the encoding, by default this procedure raises an
`encoding-error'. Pass a CONVERSION-STRATEGY argument to specify
other behaviors.
The return value is a bytevector. *Note Bytevectors::, for more on
bytevectors. *Note Ports::, for more on character encodings and
conversion strategies.
-- Scheme Procedure: bytevector->string bytevector encoding
[conversion-strategy]
Decode BYTEVECTOR into a string.
The bytes will be decoded from the character set by the ENCODING
string. If the bytes do not form a valid encoding, by default this
procedure raises an `decoding-error'. As with
`string->bytevector', pass the optional CONVERSION-STRATEGY
argument to modify this behavior. *Note Ports::, for more on
character encodings and conversion strategies.
-- Scheme Procedure: call-with-output-encoded-string encoding proc
[conversion-strategy]
Like `call-with-output-string', but instead of returning a string,
returns a encoding of the string according to ENCODING, as a
bytevector. This procedure can be more efficient than collecting a
string and then converting it via `string->bytevector'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-01 16:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01 3:12 bug#14109: No code for 'bytevector->string' and 'string->bytevector' Nikita Karetnikov
2013-04-01 11:46 ` Ian Price
2013-04-01 16:38 ` Mark H Weaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).