Re: raw-unicode-escape encoding
David Goodger <[email protected]>
| Newsgroups | gmane.comp.python.internationalization |
|---|---|
| Message-ID | <B8AE2001.1FAF7%[email protected]> |
[David Goodger] >> "a form suitable for usage in Python source code": that's exactly what >> I want. Cross-platform compatibility requires 7-bit ASCII source code. >> The raw-unicode-escape codec produces 8-bit Latin-1, which doesn't >> survive the trip to MacOS. [Martin v. Loewis] > If you put it into Python source, it sure does survive the trip to > MacOS - assuming you manage not to convert the Python source file when > putting it on a Mac disk. Unfortunately, that's an assumption that's easily broken by all kinds of well-meaning tools (browsers, unarchivers, etc.). Which is why I want a 7-bit representation. >> If I'm not mistaken, '\xa7' is *not* the same as '\u00a7' > > You are mistaken. Would I still be mistaken if I put it like this: '\xa7' is not the same as u'\u00a7'? (Note the '' and u''.) That's what the raw-unicode-escape coded is doing. > It appears then that the raw-unicode-escape codec is not suited for > your application; you will probably need to write your own. This has > the advantage that you'll know exactly what it is doing. Fair enough. Thanks for clarifying. I'll try writing a codec; at the least, it will improve my understanding of how all this fits together. >> Why Latin-1 and not 7-bit ASCII? Is that documented anywhere? > > The unicode-escape codec is not documented at all. How do you know it > exists? By using the source. :-) >> I would like to use a codec which escapes all char for ord(char) >> from 128 up, but leaves all 7-bit ASCII alone. Is there any such >> beast? > > "utf-7" fits that description, except that it will escape '+'. > Something that produces ASCII and does not escape anything does > not exist - you normally have to escape the escape character. That would be acceptable; I'll give it a try. Thank you, Martin and Marc-Andre, for your thoughtful replies. -- David Goodger [email protected] Open-source projects: - Python Docstring Processing System: http://docstring.sourceforge.net - reStructuredText: http://structuredtext.sourceforge.net - The Go Tools Project: http://gotools.sourceforge.net