Thema: Delphi Problem mit #0 im String

Einzelnen Beitrag anzeigen

Satty67

Registriert seit: 24. Feb 2007
Ort: Baden
1.566 Beiträge
 
Delphi 2007 Professional
 
#24

Re: Problem mit #0 im String

  Alt 5. Mai 2009, 09:50
Zur Visualisierung kann man sich ja auch schnell was basteln:
Delphi-Quellcode:
function VisualizeASCII(Text : String; SpaceToo : Boolean) : String;
const
  ASCII_Codes : array[#0..#31] of String = (
    '<NUL>', '<SOH>', '<STX>', '<ETX>', '<EOT>', '<ENQ>', '<ACK>', '<BEL>',
    '<BS>', '<TAB>', '<LF>', '<VT>', '<FF>', '<CR>', '<SO>', '<SI>', '<DLE>',
    '<DC1>', '<DC2>', '<DC3>', '<DC4>', '<NAK>', '<SYN>', '<ETB>', '<CAN>',
    '[i]', '<SUB>', '<ESC>', '<FS>', '<GS>', '<RS>','<US>');
  DEL_Code = '<DEL>';
  SPACE_Code = '<SPACE>';
var
  i : Integer;
begin
  Result := '';
  for i := 1 to Length(Text) do
    case Text[i] of
      #0..#31 : Result := Result + ASCII_Codes[Text[i]];
      #32 : if SpaceToo then Result := Result + SPACE_Code
               else Result := Result + ' ';
      #127 : Result := Result + DEL_Code;
    else
      Result := Result + Text[i];
    end;
end;
Bei Bedarf auch #32 als <SPACE> ...€: Done
€2: 127 ist DEL nicht ESC
  Mit Zitat antworten Zitat