win32com, BSTR, and null terminated strings

Matt Helm eric at qwhd746oihd49.net
Mon Feb 6 09:29:53 EST 2006


"John Bauman" <john at baumanfamily.com> writes:
> "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. 

No good. The string could be "ABC" + \0 + 77 more chars of random memory.

Matt




More information about the Python-list mailing list