var mStream: TMemoryStream; Strings: TStringList; buf: array[1..45] of byte; b2: array[1..4] of byte; a, b, c: byte; i, k: integer; strTmp, data: AnsiString; begin result := ''; data := ''; //result := 'begin 644 ' + #13#10; mStream := TMemoryStream.Create; Strings := TStringList.Create; try Strings.Text := S; Strings.SaveToStream(mStream); mStream.Seek(0,soBeginning); FillChar(buf, length(buf), 0); while mStream.Read(buf, length(buf)) > 0 do begin i := 1; strTmp := ''; while i <= Length(buf) do begin a := Ord(buf[i]); inc(i); b := Ord(buf[i]); inc(i); c := Ord(buf[i]); inc(i); b2[1] := a shr 2; b2[2] := ((a and 3) shl 4) or (b shr 4); b2[3] := ((b and 15) shl 2) or (c shr 6); b2[4] := c and 63; for k := 1 to Length(b2) do strTmp := strTmp + chr(b2[k] + 32); end; data := data + 'M' + strTmp + #13#10; end; finally mStream.free; Strings.Free; end; Result:=data; //result := result + data + chr(96) + #10'end'; end;