Menu

#4 Quick patch to allow reading of UNICODE

open
nobody
None
5
2007-04-01
2007-04-01
No

While SuperStream can write Unicode WideStrings just fine, it fails reading these with an exception "Reading of WideStrings not supported." Writing is working just fine, I can only assume the guys from Soletta didn't see any reason for putting any more time into that feature since Unicode is supported only by Windows NT 4.0 or higher operating systems.

I wrote a quick UNTESTED hack which is working *in my case* of writing once and reading multiple times a static database (DMap with WideString/WideString pairs). I do not give any guarantee whatsoever. Use this completely on you own risk!

Please also understand that this patch only allows reading of WideStrings. Arrays of WideStrings are still unsupported.

Fortunately WideStrings are simply strings which consists of one Word per character. So we can reuse the AnsiString routine with slight modifications.

Open SuperStream.php and locate TObjStream.TransferItemEx and change the following:

procedure TObjStream.TransferItemEx(...)
type
[...]
PWideString = ^WideString;
var
[...]
pws : PWideString;

Close to the end of the function you find:

vtWideString:
raise TObjStreamException.Create('Can''t read in wide strings.');

EXCHANGE this part with the following:

vtWideString:
begin
readFixed(len, sizeof(len));

pws := PWideString(itemAddress);
pi := PInteger(itemAddress);

if len > 0 then
begin
UniqueString(pws^);
SetLength(pws^, len DIV 2);
readFixed(pws^[1], len);
end
else
pi^ := 0;

end;

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.