Liam Clarke wrote:
> So, using
>
> val = unicode(value)
> self._slaveMap[attr].setPayload(value.encode("UTF-16"))
>
> I can stick normal strings in happily. Of course, as you mentioned,
> Kent, this leaves me vulnerable if the string differs to
> sys.getdefaultencoding().
>
> Other than directly
Hi Kent,
> > return self.location
> > def sLoc(self, value):
> > #Need to coerce data into UTF-16 here
> > self.mhod.payload = value.encode("UTF-16")
>
> I'm confused about what sLoc is supposed to do. Shouldn't it be setting
> self.location? ISTM sLoc should parallel
Liam Clarke wrote:
> I have a base object, which reads the unicode string as bytes like so,
> this ignores all but important bits.
>
> class Mhod:
> def __init__(self, f):
> self.payload = struct.unpack("36s", f.read(36))
>
> Which in turn, is utilised in a Song object, which works li
Hmm, looking at this, it seems I'm not the only one with this sort of problem.
http://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf
Maybe I will just build a wall around these objects and declare
"none but unicode shall pass."
On 10/3/05, Liam Clarke <[EM
OK, one last kick.
So, using
val = unicode(value)
self._slaveMap[attr].setPayload(value.encode("UTF-16"))
I can stick normal strings in happily. Of course, as you mentioned,
Kent, this leaves me vulnerable if the string differs to
sys.getdefaultencoding().
Other than directly from the user, the
Liam Clarke wrote:
> Basically, I have data which is coming straight from struct.unpack()
> and it's an UTF-16 string, and I'm just trying to get my head around
> dealing with the data coming in from struct, and putting my data out
> through struct.
>
> It doesn't help overly that struct considers
Hi,
If I can just beat this horse one more time, can I just get
confirmation that I'm going about this the right way?
I have a base object, which reads the unicode string as bytes like so,
this ignores all but important bits.
class Mhod:
def __init__(self, f):
self.payload = struct.u
Thanks Kent,
My first time dealing with Python and unicode vs 'normal' strings, I
do look forward to Python 3.0... at the moment I'm just trying to
understand how to use UTF-16.
Basically, I have data which is coming straight from struct.unpack()
and it's an UTF-16 string, and I'm just trying to
Liam Clarke wrote:
> What's the difference between
>
> x = "Hi"
> y = x.encode("UTF-16")
>
> and
>
> y = unicode(x, "UTF-16")
They are more-or-less opposite.
encode() converts away from unicode. (Think of unicode as the 'normal' format,
anything else in 'encoded'.) Normally it is used on a un
Hi all,
Just got a bit of confusion with trying to use struct with unicode.
What's the difference between
x = "Hi"
y = x.encode("UTF-16")
and
y = unicode(x, "UTF-16")
Regards,
Liam Clarke
___
Tutor maillist - Tutor@python.org
http://mail.python.o
10 matches
Mail list logo