Yep.  I would truncate the buffer before heading into GetBufferAsUTF8 since the walk-back-and-truncate approach should yield a valid data stream.