[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11197: problems with string ports and unicode
From: |
Ludovic Courtès |
Subject: |
bug#11197: problems with string ports and unicode |
Date: |
Wed, 11 Apr 2012 18:25:10 +0200 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) |
Hi Mark,
Mark H Weaver <address@hidden> skribis:
> address@hidden (Ludovic Courtès) writes:
>> It may be that your string ports are created with a non-Unicode-capable
>> encoding. Try something like:
>>
>> (define p
>> (with-fluids ((%default-port-encoding "UTF-8"))
>> (open-input-string "čtyří")))
>
> IMO, this should not be needed. Port encodings should only be relevant
> when reading from ports involving byte strings, such as file ports or
> socket ports. The encoding used by Scheme strings is a purely internal
> matter; from the user's perspective, Scheme strings are simply a
> sequence of Unicode code points.
Note that “UTF-8” above has nothing to do with Guile’s internal string
representation; it’s just one of the many encodings that can represent
“čtyří”.
> What _is_ needed is a file coding declaration near the top of the source
> file, e.g. "coding: utf-8" (see "Character Encoding of Source Files" in
> the manual).
Yes. And you actually need both–i.e., the ‘coding’ cookie won’t
magically make string ports use that encoding.
> I tried that and it still fails for me.
What fails exactly?
Thanks,
Ludo’.