guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile can't find a chinese named file


From: Eli Zaretskii
Subject: Re: guile can't find a chinese named file
Date: Fri, 17 Feb 2017 11:07:28 +0200

> From: Marko Rauhamaa <address@hidden>
> Cc: address@hidden,  address@hidden
> Date: Fri, 17 Feb 2017 10:46:32 +0200
> 
> > IMO, it makes no sense to limit this to file names, because (a) you
> > don't always know on all levels of the code which string is a file
> > name or a part thereof; and (b) because situations where non-ASCII
> > bytes cannot be properly decoded into Unicode happen with text that is
> > not file names, and users still expect Emacs to silently produce the
> > same byte stream on round-trip operations, e.g., when copying text
> > from one file to another.
> 
> Python just barfs:
> 
>    $ python3 -c "import sys; print(sys.stdin.read(30))" <<<$'\xdd'
>    Traceback (most recent call last):
>      File "<string>", line 1, in <module>
>      File "/usr/lib64/python3.5/codecs.py", line 321, in decode
>        (result, consumed) = self._buffer_decode(data, self.errors, final)
>    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position \
>    0: invalid continuation byte

Which is a bad idea, IME: users won't appreciate their program to barf
when all they want is to copy a chunk of text from one place to
another, without changing anything in it.

> The situation is a bit difficult to recover from.

If you assume valid UTF-8 everywhere, certainly.  The world is more
complex than that.  Emacs is known to be used for, e.g., searching
binary executable files for text patterns; if it required the user to
say in advance that the file was binary, so that Emacs could handle it
as a byte array, that would be a major annoyance, and worse: it would
prevent the users from searching valid non-ASCII text in such a binary
file.  So Emacs allows treating binary files as text files with a
certain encoding that have some raw bytes which don't fit that
encoding.  IMO, Guile will do its users a service if it provides
similar features, because applications with similar needs are entirely
reasonable in today's world.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]