RE: Unicode string handling
"Simon C" <[email protected]>
| Newsgroups | gmane.comp.mobile.bitpim.devel |
|---|---|
| Message-ID | <000501c65d2c$f9ac4a40$0201a8c0@HOME> |
> >I have taken the string keywords/parameters as applying to > the strings > >written to or read from the phone > > As an exmample, you're writing a unicode string to the phone > and its physical length is more 'sizeinbytes', how would you > truncate the string/value/field? You would truncate it until it fits the size available, the byte length is the limiting factor not the number of characters. I have implemented it to work this way at the moment if you look at the _update function. Also python has interesting behavior with the 'len' of byte srings, it returns the number of bytes not characters, for unicode strings it returns the number of characters. > >There is a problem at the moment with handling terminators > of more than > >one byte > > Untill this issue is addressed, current handling of unicode > strings will not work in all cases. None of the phones use more than a single byte for terminating characters afaik, so the limitation is theoretical, it was also present before I made any changes. Conversion to unicode has always happened in bitpim, the changes to the string class move it to a different point in the code, the advantage to the doing it this way is that we can now control the character set used for the converstion. > >If maintaining compatability with existing code is most important > > IMHO, I think it is just because we may not have access to > all the phones implemented in BitPim to easily make (and > test) any updates. I think the safest way to do this would be to deprecate the STRING class and leave it untouched and introduce a new one for unicode support. We would then be able to migrate the existing code over as time allowed. It would be possible to add the graceful degrade to ascii feature to the existing STRING class without significant risk, its just a one or two line change. I see your point about backward compatability, it will not take long to add a separate class. Anyone object? Simon ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642