AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

$0 in stream and loading as text

Ein Thema von WojTec · begonnen am 24. Aug 2014 · letzter Beitrag vom 25. Aug 2014
Antwort Antwort
Seite 2 von 2     12
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#11

Re: $0 in stream and loading as text

  Alt 25. Aug 2014, 17:06
@Sir Rufo, next time I'll be more precise
Data producer is unknown, I just know it is some resource compiler + compiler + linker (mean file is executable). Data is some data, it can be in any format, it can be a string too.

I wrote simple function to check if stream can be Unicode or ANSII:

Delphi-Quellcode:
function GetEncoding(AStream: TStream): TEncoding;
var
  V: Byte;
begin
  Result := TEncoding.ANSI;

  if AStream.Size > 1 then
  begin
    AStream.Position := 1;
    AStream.ReadBuffer(V, 1);
    if V = 0 then
      Result := TEncoding.Unicode
    ;
  end;
end;
Another one, I badly loaded encoded text (LoadFromStream - it was raw data, stupilo ), Append(DataString) is required.

As @brechi told, pointer terminate code is zero in TStrings, so this is main problem. I don't know how jump over it

Also I wrote poor (because very slow) procedure to replace bytes in stream, if someone need it:

Delphi-Quellcode:
procedure ReplaceBytes(AIn: TStream; const AFrom, ATo: Byte; AOut: TStream);
var
  I: Cardinal;
  V: Byte;
begin
  for I := 1 to AIn.Size do
  begin
    AIn.ReadBuffer(V, 1);

    if V = AFrom then
      AOut.WriteBuffer(ATo, 1)
    else
      AOut.WriteBuffer(V, 1)
    ;
  end;
end;
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz