AGB  ·  Datenschutz  ·  Impressum  







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

Dostounix

Ein Thema von bernhard_LA · begonnen am 8. Jan 2014 · letzter Beitrag vom 8. Jan 2014
Antwort Antwort
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#1

Dostounix

  Alt 8. Jan 2014, 12:52
Hat jemand mal ein schöne Implementierung für DOSTOUNIX ??

UNIX2DOS habe ich schon


Delphi-Quellcode:
procedure Unix2Dos(UnixTEXTFile, DosTEXTFile : String);
Const CR : Char = #13;
      LF = #10;
Var InFile, OutFile : File;
    InByte : Char;

begin
  Assign (InFile, UnixTEXTFile); ReSet (InFile, 1);
  Assign (OutFile, DosTEXTFile); ReWrite (OutFile, 1);
  while NOT EOF (InFile) do
    begin
      BlockRead (InFile, InByte, 1);
      if InByte = LF then BlockWrite (OutFile, CR, 1);
      BlockWrite (OutFile, InByte, 1);
    end;
  Close (OutFile);
  Close (InFile);
end;
  Mit Zitat antworten Zitat
Mikkey

Registriert seit: 5. Aug 2013
265 Beiträge
 
#2

AW: Dostounix

  Alt 8. Jan 2014, 12:58
Wenn es bei dem Muster bleiben soll:

Delphi-Quellcode:
      if InByte <> CR then
        BlockWrite (OutFile, InByte, 1);
Macht allerdings keinen besonders performanten Eindruck.
  Mit Zitat antworten Zitat
Benutzerbild von guinnes
guinnes

Registriert seit: 28. Feb 2007
Ort: Bottrop
265 Beiträge
 
Delphi 5 Enterprise
 
#3

AW: Dostounix

  Alt 8. Jan 2014, 13:06
Hat jemand mal ein schöne Implementierung für DOSTOUNIX ??

UNIX2DOS habe ich schon


Delphi-Quellcode:
procedure Unix2Dos(UnixTEXTFile, DosTEXTFile : String);
Const CR : Char = #13;
      LF = #10;
Var InFile, OutFile : File;
    InByte : Char;

begin
  Assign (InFile, UnixTEXTFile); ReSet (InFile, 1);
  Assign (OutFile, DosTEXTFile); ReWrite (OutFile, 1);
  while NOT EOF (InFile) do
    begin
      BlockRead (InFile, InByte, 1);
      if InByte = LF then BlockWrite (OutFile, CR, 1);
      BlockWrite (OutFile, InByte, 1);
    end;
  Close (OutFile);
  Close (InFile);
end;
Warum solch einen Zirkus ? In eine Stringliste einlesen und mit SaveToFile wieder speichern und gut ist
Glückauf
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: Dostounix

  Alt 8. Jan 2014, 16:26
Vor allem macht das Sinn, wenn man eine Textdatei mit einem Multibyte-Encoding verarbeiten will
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
Antwort Antwort


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:21 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