emacs-devel
[Top][All Lists]
Advanced

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

Re: Encoding for a file containing filenames?


From: Stefan Monnier
Subject: Re: Encoding for a file containing filenames?
Date: Fri, 09 Nov 2007 11:25:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

>>>> But it will fail in Emacs-22 if the file (which contains file names)
>>>> contains chars that Emacs-22 doesn't know how to encode to (and decode
>>>> from) utf-8.
>> > Are there any such chars that are likely to be used in filenames? Or is it
>> > just the mule specific charsets that Emacs-22 cannot encode as utf-8.

>> It's actually a bit worse: it shouldn't just be encodable with utf-8,
>> but it should also be the case that encoding to utf-8 and back should
>> return the exact same string (since these are filenames and will be
>> compared with simple byte-comparison in the kernel).

> I think the important thing is to assure the round-trip of
> decode&encode (not encode&decode).

Are you sure?  The situation is that we have a file name as an Emacs
string (i.e. decoded say from "locale" coding system) and we need to
store it into a file to load it back in a later Emacs invocation (at
which point we may use it to access the file, using hopefully the same
"locale" coding system).

So what needs to be byte-preserving is really:

  locale-decode -> utf8-encode -> utf8-decode -> locale-encode

So as Eli points out, if locale is utf-8 there shouldn't be any problem.
In any case, I'd go with utf-8.


        Stefan




reply via email to

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