[IronPython] How to convert from byte[] to str ?

Dino Viehland dinov at microsoft.com
Fri Dec 18 10:05:27 PST 2009


The best reference is probably going to be IronPython.xml which contains 
all of the doc comments pulled out.  Other than that there's not really a 
good reference for these.

And unfortunately it's further complicated  by the fact that some things 
in PythonOps are really pretty static and meant are fine for consumption 
by anyone.  Other things are really just calls that we need to emit from 
generated code and so they need to be somewhere and public.  

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of David McWright
> Sent: Friday, December 18, 2009 9:01 AM
> To: users at lists.ironpython.com
> Subject: Re: [IronPython] How to convert from byte[] to str ?
> 
> Dino,
>    Is there somewhere I can find a reference for the other helpers in
> PythonOps?
> 
> Thanks,
> David
> 
> On Dec 17, 9:33 pm, Dino Viehland <di... at microsoft.com> wrote:
> > We have helpers in PythonOps called MakeByteArray and MakeString which
> > do the conversion.  To use these from Python you can do:
> >
> > import clr
> > clr.AddReference('IronPython')
> > from IronPython.Runtime.Operations import PythonOps
> > pickled = PythonOps.MakeString(record.data)
> >
> >
> >
> > > -----Original Message-----
> > > From: users-boun... at lists.ironpython.com [mailto:users-
> > > boun... at lists.ironpython.com] On Behalf Of KATO Kanryu
> > > Sent: Thursday, December 17, 2009 6:30 PM
> > > To: Discussion of IronPython
> > > Subject: [IronPython] How to convert from byte[] to str ?
> >
> > > Hi,
> >
> > > How to convert from byte[] to str without converted ?
> >
> > > I'm saveing datas as records to System.Data.SQLite with using cPickle.
> > > There are defined pickled data column as 'blob' type.
> > > The cPickle.dumps() outputs as str type.
> > > When we read 'blob' column as byte[] type.
> > > cPickle.loads() gets str type, and I must convert from byte[] to str.
> >
> > > Now I call the following:
> >
> > > pickled = Encoding.UTF8.GetString(record.data)
> > > data = cPickle.loads(pickled)
> >
> > > But, GetString sometimes failed :(
> >
> > > KATO Kanryu
> > > _______________________________________________
> > > Users mailing list
> > > Us... at lists.ironpython.com
> > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> > _______________________________________________
> > Users mailing list
> > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-
> ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the Users mailing list