Saving (unusual) linux filenames

Alan Meyer ameyer2 at yahoo.com
Wed Sep 1 02:20:12 CEST 2010


On 8/31/2010 2:33 PM, Nobody wrote:

...
> FWIW, my usual solution is URL-encoding (i.e. replacing any "awkward"
> character by a "%" followed by two hex digits representing the byte's
> value). It has the advantage that you can extend the set of bytes which
> need encoding as needed without having to change the code (e.g. you can
> provide a command-line argument or configuration file setting which
> specifies which bytes need to be encoded).

I like that one.

A similar solution is to use an escape character, e.g., backslash, e.g., 
"This is a backslash\\ and this is a comma\,."

However, because the comma won't appear at all in the URL-encoded 
version, it has the virtue of still allowing you to split on commas.

You must of course also URL encode the '%' as %25, e.g.,
"Here is a comma (%2C) and this (%2C) is a percent sign."

     Alan



More information about the Python-list mailing list