Re: USTRING "encoding" behavior different from STRING's?
Perry Nguyen <[email protected]>
| Newsgroups | gmane.comp.mobile.bitpim.devel |
|---|---|
| Message-ID | <[email protected]> |
Indeed, I do have a problem with the USTRING class, and my packet looks like
as follows:
PACKET obex_header:
P DATA data "the actual header data"
1 UINT headerId "one of the OBEX_HDR types"
if self.headerId & com_obex.OBEX_HI_MASK == com_obex.OBEX_UNICODE:
# additional +1 to account for terminator
# utf_16be = big endian, seems obex goes by this?
2 UINT { 'value': htons(len(self.data.encode("utf_16be")) + 4) }
+headerSize
* USTRING { 'encoding': "utf_16be", 'value': self.data } +headerData
if self.headerId & com_obex.OBEX_HI_MASK == com_obex.OBEX_BYTE_STREAM:
2 UINT { 'value': htons(len(self.data) + 3) } +headerSize
* DATA { 'value': self.data } +headerData
if self.headerId & com_obex.OBEX_HI_MASK == com_obex.OBEX_BYTE:
1 UINT { 'value': self.data } +headerData
if self.headerId & com_obex.OBEX_HI_MASK == com_obex.OBEX_INT:
4 UINT { 'value': htonl(self.data) } +headerData
Basically, I call p_obex.obex_header(), set the headerId and data fields, when
it comes time to write the packet, headerData and headerSize are populated
automatically. Previously, with STRING, the UNICODE headerData would be
populated correctly with the encoded value of 'data'.
Anyway, excuse me if I exercised bad practice in the packet setup, I'm a newb
when it comes to python.
Simon C wrote:
> The encoding keyword was only temporary in the STRING class, we decided
> not to include it in favor of introducing USTRING and deprecating STRING
> to reduce impact on existing code.
> You should not use STRING any more.
>
> It sounds like you are having a problem with the USTRING class. Do you
> have the latest updates? Can you provide an example of the packet you
> defined?
>
> Simon
>
>
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642