AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Vermutlich Hex Daten Umwandeln

Ein Thema von Dumpfbacke · begonnen am 31. Mär 2019 · letzter Beitrag vom 8. Apr 2019
 
Schokohase
(Gast)

n/a Beiträge
 
#27

AW: Vermutlich Hex Daten Umwandeln

  Alt 3. Apr 2019, 22:32
Delphi-Quellcode:
program Project2;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils;

function BytesToHexView(const ABytes: TBytes): string;
var
  hex, str: string;
  idx, len, len2: Integer;
  b: Byte;
begin
  Result := string.Empty;
  len := Length(ABytes);
  hex := string.Empty;
  str := string.Empty;

  if len mod 16 = 0 then
    len2 := len
  else
    len2 := len + 16 - len mod 16;

  for idx := 1 to len2 do
  begin
    if idx <= len then
    begin
      b := ABytes[idx - 1];
      hex := hex + IntToHex(b, 2) + ' ';
      if b < 32 then
        str := str + '.'
      else
        str := str + Chr(b);
    end
    else
    begin
      hex := hex + ' ';
      str := str + ' ';
    end;
    if idx mod 16 = 0 then
    begin
      if not string.IsNullOrEmpty(Result) then
        Result := Result + sLineBreak;
      Result := Result + hex + '| ' + str;

      hex := string.Empty;
      str := string.Empty;
    end;
  end;
end;

begin
  try
    Writeln(BytesToHexView([ //
      $05, $03, $01, $01, $04, $02, $00, $00, $00, $00, $00, $00, $01, $01, $04, $02, //
      $00, $00, $00, $00, $00, $00, $01, $01, $04, $02, $00, $00, $00, $00, $00, $00, //
      $01, $01, $04, $02, $00, $00, $00, $00, $00, $00, $01, $01, $04, $02, $00, $00, //
      $00, $00, $00, $00, $01, $01, $04, $02, $00, $00, $00, $00, $00, $00, $01, $01, //
      $04, $02, $06, $00, $00, $00, $50, $00, $72, $00, $69, $00, $76, $00, $61, $00, //
      $74, $00, $00, $00, $02, $01, $00, $01, $FA, $B8, $8A, $42, $FB, $53, $48, $80]));
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;

end.
Code:
05 03 01 01 04 02 00 00 00 00 00 00 01 01 04 02 | ................
00 00 00 00 00 00 01 01 04 02 00 00 00 00 00 00 | ................
01 01 04 02 00 00 00 00 00 00 01 01 04 02 00 00 | ................
00 00 00 00 01 01 04 02 00 00 00 00 00 00 01 01 | ................
04 02 06 00 00 00 50 00 72 00 69 00 76 00 61 00 | ......P.r.i.v.a.
74 00 00 00 02 01 00 01 FA B8 8A 42 FB 53 48 80 | t.......ú¸?BûSH?
  Mit Zitat antworten Zitat
 


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 10:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz