[Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?]

INADA Naoki songofacandy at gmail.com
Wed Jan 8 12:53:26 CET 2014


FYI, I can make sample data that is not roundtrip easily with iso2022-jp
encoding.

In [5]: b'\x1b$B\x1b(B'.decode('iso2022_jp')
Out[5]: ''

In [6]: b'\x1b$B\x1b(B'.decode('iso2022_jp',
'surrogateescape').encode('iso2022_jp', 'surrogateescape')
Out[6]: b''


On Wed, Jan 8, 2014 at 8:38 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Wed, 8 Jan 2014 20:31:10 +0900
> INADA Naoki <songofacandy at gmail.com>
> wrote:
> >
> > You're right. I've not considered using surrogateescape here.
> >
> > But MySQL connection may be not utf8. It's default latin1 and you can use
> > many encoding.
> > Some encoding doesn't ensure roundtrip. In such encoding,
> >
> [...]
> >
> > But I think decode/encode with surrogateescape is not only slow, but also
> > dangerous when using
> > encoding except ascii or utf8.
>
> You're right. Thanks exposing your use case, I think it's a good data
> point for the bytes formatting PEP.
>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
INADA Naoki  <songofacandy at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140108/4e5de88b/attachment.html>


More information about the Python-ideas mailing list