win32com, BSTR, and null terminated strings

Steve Holden steve at holdenweb.com
Mon Feb 6 08:40:58 EST 2006


John Bauman wrote:
> "Matt Helm" <eric at qwhd746oihd49.net> wrote in message 
> news:mzh5xzyr.fsf at qwhd746oihd49.net...
> 
>>However, what is the proper way to recover the actual string? I have
>>been using:
>>
>>   r.split("\0", 1)[0]
>>
> 
> I'd prefer to use
> r[:-1]
> to strip off the last character of the string. 
> 
> 
Unfortunately there's no guarantee that the string occupies the whole of 
the returned buffer: the first zero byte terminates the string.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list