From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: Andy Wingo <wingo@pobox.com>
Cc: 26058@debbugs.gnu.org
Subject: bug#26058: utf16->string and utf32->string don't conform to R6RS
Date: Thu, 16 Mar 2017 20:34:14 +0100 [thread overview]
Message-ID: <87r31xdnih.fsf@gmail.com> (raw)
In-Reply-To: <877f3r7ti2.fsf@pobox.com> (Andy Wingo's message of "Tue, 14 Mar 2017 16:44:37 +0100")
Andy Wingo <wingo@pobox.com> writes:
> Adopting the behavior is more or less fine. If it can be done while
> relying on the existing behavior, that is better than something ad-hoc
> in a module.
You mean somehow leveraging the existing BOM handling code of Guile
(found in the ports code) would be preferable to reimplementing it like
in this patch, correct?
In that light, I had this attempt:
(define r6rs-utf16->string
(case-lambda
((bv default-endianness)
(let* ((binary-port (open-bytevector-input-port bv))
(transcoder (make-transcoder (utf-16-codec)))
(utf16-port (transcoded-port binary-port transcoder)))
;; XXX how to set default-endianness for a port?
(get-string-all utf16-port)))
((bv endianness endianness-mandatory?)
(if endianness-mandatory?
(utf16->string bv endianness)
(r6rs-utf16->string bv endianness)))))
As commented in the first branch of the case-lambda, this does not yet
make use of the 'default-endianness' parameter to tell the port
transcoder (or whoever) what to do in case no BOM is found in the
stream.
From what I can tell, Guile is currently hardcoded to *transparently*
default to big-endian in ports.c, port_clear_stream_start_for_bom_read.
Is there a way to detect when Guile was unable to find a BOM? (In that
case one could set the endianness explicitly to the desired default.)
Or do you see another way to implement this?
Thanks for the feedback!
Taylan
P.S.: Huge congrats on the big release. :-)
next prev parent reply other threads:[~2017-03-16 19:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-11 12:19 bug#26058: utf16->string and utf32->string don't conform to R6RS "Taylan Ulrich Bayırlı/Kammer"
2017-03-13 13:03 ` Andy Wingo
2017-03-13 18:10 ` Taylan Ulrich Bayırlı/Kammer
2017-03-13 21:24 ` Andy Wingo
2017-03-14 15:03 ` Taylan Ulrich Bayırlı/Kammer
2017-03-14 15:44 ` Andy Wingo
2017-03-16 19:34 ` Taylan Ulrich Bayırlı/Kammer [this message]
2018-10-15 4:57 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r31xdnih.fsf@gmail.com \
--to=taylanbayirli@gmail.com \
--cc=26058@debbugs.gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).