[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string port encodings
From: |
Mark H Weaver |
Subject: |
Re: string port encodings |
Date: |
Tue, 15 Jan 2013 13:46:59 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
Hi Andy,
Andy Wingo <address@hidden> writes:
> Quiz: what does this do?
>
> (define (f s)
> (with-output-to-string (lambda () (display s))))
>
> When called with a string, what should it do? Like (f "foo").
>
> If you answered, "return the string", that's what I would think it
> should do.
>
> But no, currently the answer is locale-specific. It encodes the string
> according to the current locale, then decodes it from that encoding. If
> your locale can't encode the string, tough luck for you!
>
> This is a bit crazy. Surely the port should be textual? Surely the
> default encoding for a string port should be utf-8 or something that can
> actually handle all strings?
I agree wholeheartedly. Unfortunately, the current broken behavior of
string ports has been recommended in our official forums as a clever way
to do arbitrary iconv conversions. Nonetheless, I still think it ought
to be fixed properly in 2.2.
Here are some past discussions on this topic:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11197
http://comments.gmane.org/gmane.lisp.guile.devel/14533
Mark