View Issue Details

IDProjectCategoryView StatusLast Update
0006708JEDI Code LibraryJclStringConversionspublic2020-12-21 17:21
ReportermarkjonesnzAssigned To 
Status newResolutionopen 
Product VersionVersion 2.5 (Subversion repository/Daily zips) 
Target VersionFixed in Version 
Summary0006708: AnsiGetNextCharFromStream gives incorrect results for characters in extended range ($80 - $FF)
DescriptionThe various AnsiGetNextChar* function give different results with FromStream giving a result that is not part of the current ansi code page. With a system code page of 1252 the following gives wrong result
AnsiGetNextCharFromStream(Stream, Ch)

The following however gives the correct result
AnsiGetNextCharFromStream(Stream, 1252, Ch)
Steps To Reproducetype
  String1252 = type AnsiString(1252);
  S1, S2, S3, S4 : String1252;
  Ch: UCS4;
  ChArray: TUCS4Array;
  Bytes: TBytes;
  BytesStream: TBytesStream;
  Start: SizeInt;
  DefaultSystemCodePage := 1252;
  S1 := AnsiChar(WideChar($20AC)); //Euro
  assert(PByte(S1)^ = $80, 'Expected $80 for CP1252 Euro character');
  SetLength(Bytes, 1);
  Bytes[0] := PByte(S1)^;
  BytesStream := TBytesStream.Create(Bytes);
    assert(AnsiGetNextCharFromStream(BytesStream, Ch), 'AnsiGetNextCharFromStream failed');
    S2 := UCS4ToAnsiChar(Ch);
    assert(S1 = S2, 'S1 <> S2');

    BytesStream.Position := 0;
    assert(AnsiGetNextCharFromStream(BytesStream, 1252, Ch), 'AnsiGetNextCharFromStream (with CodePage) failed');
    S3 := UCS4ToAnsiChar(Ch);
    assert(S1 = S3, 'S1 <> S3');

    BytesStream.Position := 0;
    SetLength(ChArray, 1);
    Start := 0;
    assert(AnsiGetNextBufferFromStream(BytesStream, ChArray, Start, 1) = 1, 'AnsiGetNextBufferFromStream failed');
    S4 := UCS4ToAnsiChar(ChArray[0]);
    assert(S1 = S4, 'S1 <> S4');
TagsNo tags attached.
Fixed in GIT commit
Fixed in SVN revision
IDE versionAll


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-12-21 17:21 markjonesnz New Issue