kooloveme / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
0 stars 0 forks source link

TBuffer.AsString problem #222

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Which steps will reproduce the problem?

If I load some HTML in THtmlView and then call TBuffer.AsString subsequently a 
few times (I call it in the ParseBegin event), it returns different results. 
Sometimes it is part of the string, sometimes it reads completely different 
block of the memory, it seems.

If I use GetString(0, Source->Size()), I do not get this problem.

What is the expected output? What do you see instead?

It should return the same string always.

Which version of the product are you using? Which compiler version are you
using? On which operating system?

I have this problem with r342 under C++Builder 2010.

Original issue reported on code.google.com by kafedji...@gmail.com on 7 Dec 2012 at 8:06

GoogleCodeExporter commented 9 years ago
TBuffer.AsString returns the remaining part of the buffer which hasn't been 
read yet. Thus it could return less than GetString(0, Source->Size()). But in 
the ParseBegin event it should be the same of course as long as the buffer does 
not start with a BOM. In this case GetString() would return some rubbish.

These thoughts let me assume, that you feed HtmlViewer with a unicode string or 
UTF16LE file without BOM. I found and fixed an error in TBuffer.AsString() 
regarding UTF16LE sources.

r343 fixes the error I found. Could you please test, whether it fixes your's as 
well?

Original comment by OrphanCat on 9 Dec 2012 at 6:33

GoogleCodeExporter commented 9 years ago

Original comment by OrphanCat on 25 Jan 2013 at 5:17

GoogleCodeExporter commented 9 years ago
I close this issue after getting no answer in the past almost 4 months. 
Most probably r343 fixed the issue.

Original comment by OrphanCat on 30 Mar 2013 at 8:30