GNU bug report logs - #14109
No code for 'bytevector->string' and 'string->bytevector'

Previous Next

Package: guile;

Reported by: Nikita Karetnikov <nikita <at> karetnikov.org>

Date: Mon, 1 Apr 2013 04:39:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 14109 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#14109; Package guile. (Mon, 01 Apr 2013 04:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nikita Karetnikov <nikita <at> karetnikov.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Mon, 01 Apr 2013 04:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nikita Karetnikov <nikita <at> karetnikov.org>
To: bug-guile <at> gnu.org
Subject: No code for 'bytevector->string' and 'string->bytevector'
Date: Mon, 01 Apr 2013 07:12:06 +0400
[Message part 1 (text/plain, inline)]
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
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#14109; Package guile. (Mon, 01 Apr 2013 11:57:02 GMT) Full text and rfc822 format available.

Message #8 received at 14109 <at> debbugs.gnu.org (full text, mbox):

From: Ian Price <ianprice90 <at> googlemail.com>
To: Nikita Karetnikov <nikita <at> karetnikov.org>
Cc: 14109 <at> debbugs.gnu.org
Subject: Re: bug#14109: No code for 'bytevector->string' and
	'string->bytevector'
Date: Mon, 01 Apr 2013 12:46:59 +0100
Nikita Karetnikov <nikita <at> 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"




Information forwarded to bug-guile <at> gnu.org:
bug#14109; Package guile. (Mon, 01 Apr 2013 16:42:02 GMT) Full text and rfc822 format available.

Message #11 received at 14109 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Ian Price <ianprice90 <at> googlemail.com>
Cc: Nikita Karetnikov <nikita <at> karetnikov.org>, 14109 <at> debbugs.gnu.org
Subject: Re: bug#14109: No code for 'bytevector->string' and
	'string->bytevector'
Date: Mon, 01 Apr 2013 12:38:12 -0400
Ian Price <ianprice90 <at> googlemail.com> writes:

> Nikita Karetnikov <nikita <at> 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'.




Severity set to 'wishlist' from 'normal' Request was from Mark H Weaver <mhw <at> netris.org> to control <at> debbugs.gnu.org. (Thu, 05 Dec 2013 04:07:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 256 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.