@@ -1554,16 +1554,18 @@ Var
B : TBytes;
Buf : TJSArrayBuffer;
BytesLeft : Integer;
+ ByteCount : Integer;
begin
// Top off
+ ByteCount:=Count*2; // UTF-16
BytesLeft:=(Size-Position);
- if BytesLeft<Count then
- Count:=BytesLeft;
- SetLength(B,Count);
- ReadBuffer(B,0,Count);
+ if BytesLeft<ByteCount then
+ ByteCount:=BytesLeft;
+ SetLength(B,ByteCount);
+ ReadBuffer(B,0,ByteCount);
Buf:=BytesToMemory(B);
- Result:=BufferToString(Buf,0,Count);
+ Result:=BufferToString(Buf,0,ByteCount);
end;
procedure TStringStream.WriteString(const AString: string);
@@ -167,11 +167,16 @@ procedure TTestStringStream.TestReadString;
Var
S : String;
+
S:='ABCDEFGH';
DoCreate(S);
- AssertEquals('2 characters','AB',Stream.ReadString(4));
- AssertEquals('Top off characters','CDEFGH',Stream.ReadString(22));
+ AssertEquals('2 characters','AB',Stream.ReadString(2));
+ AssertEquals('Top off characters','CDEFGH',Stream.ReadString(11));
+ S:='Hello World';
+ FreeAndNil(FStream);
+ DoCreate(S);
+ AssertEquals('Correct string',S,Stream.ReadString(Length(S)));
procedure TTestStringStream.TestWriteString;
@@ -38,7 +38,7 @@
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
- <Filename Value="testrtl.html"/>
+ <Filename Value="index.html"/>
<CustomData Count="1">
<Item0 Name="PasJSIsProjectHTMLFile" Value="1"/>
@@ -26,7 +26,7 @@ program testrtl;
uses
browserconsole, consoletestrunner, frmrtlrun, simplelinkedlist,
-// tcstream,
+ tcstream,
// tccompstreaming,
// tcsyshelpers,
// tcgenarrayhelper,