Re: Reversing \N{...} notation?

2016-10-27 Thread Serhiy Storchaka
On 26.10.16 23:47, Peter Otten wrote: def mynamereplace(exc): return u"".join( "\\N{%s}" % unicodedata.name(c) for c in exc.object[exc.start:exc.end] ), exc.end codecs.register_error("namereplace", mynamereplace) Not all characters has standard na

Re: Reversing \N{...} notation?

2016-10-26 Thread Peter Otten
Tim Chase wrote: > On 2016-10-25 20:14, Peter Otten wrote: >> Tim Chase wrote: >> > I like the clarity of using the "\N{...}" notation when creating >> > string literals involving Unicode chars. >> > >> > Is there a built-in way to get such strings back from Python? >> >> >>> 'mañana'.encode("as

Re: Reversing \N{...} notation?

2016-10-26 Thread Tim Chase
On 2016-10-25 20:14, Peter Otten wrote: > Tim Chase wrote: > > I like the clarity of using the "\N{...}" notation when creating > > string literals involving Unicode chars. > > > > Is there a built-in way to get such strings back from Python? > > >>> 'mañana'.encode("ascii", "namereplace").decode

Re: Reversing \N{...} notation?

2016-10-25 Thread Peter Otten
Tim Chase wrote: > I like the clarity of using the "\N{...}" notation when creating > string literals involving Unicode chars. > > Is there a built-in way to get such strings back from Python? > > >>> s = 'ma\N{LATIN SMALL LETTER N WITH TILDE}ana' > >>> s > 'mañana' > >>> magic(s) > 'ma\\N{

Reversing \N{...} notation?

2016-10-25 Thread Tim Chase
I like the clarity of using the "\N{...}" notation when creating string literals involving Unicode chars. Is there a built-in way to get such strings back from Python? >>> s = 'ma\N{LATIN SMALL LETTER N WITH TILDE}ana' >>> s 'mañana' >>> magic(s) 'ma\\N{LATIN SMALL LETTER N WITH TILDE}ana'