Le jeudi 22 mai 2008 à 10:55 -0700, Guido van Rossum a écrit : > Hi folks, > > Is this thread reaching a conclusion yet? I am hoping I can soon > accept some variant of the following: > > 1. repr() returns a Unicode string containing only printable Unicode > characters, using \x\u\U escapes for characters that are not > considered printable according to some version of the Unicode standard > augmented with some Python practicality, but unaffected by platform or > locale. This can be implemented efficiently, without having to load > the whole Unicode database, at least for strings containing only a > large subset of the Unicode character set (e.g. all of UCS2, and > possibly whole ranges of UCS4). > > 2. If you don't want any non-ASCII printed to a file, set the file's > encoding to ASCII and the error handler to backslashescape.
Since some people still seem wary that repr() might return non-ascii results, perhaps we could also: 3. Add a builtin function named ascii() and a formatting code "%a" that both call repr() internally and then convert all non-ascii characters to \uXXXX escapes. 2to3 might even replace all occurrences of repr() by ascii(), to err on the safe side. Regards Antoine. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com