GNU bug report logs -
#11197
problems with string ports and unicode
Previous Next
Full log
Message #14 received at 11197 <at> debbugs.gnu.org (full text, mbox):
Hi Mark,
Mark H Weaver <mhw <at> netris.org> skribis:
> ludo <at> gnu.org (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’.
This bug report was last modified 12 years and 334 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.