2018年4月25日 星期三

捕捉DOS輸出



Thundax Output 


Кодировка из Win в DOS и из DOS в Win в Delphi 2010 
URL
google

function WinToDos(ASource: String): AnsiString;
var
Ch: PAnsiChar;
begin
Ch := AnsiStrAlloc(Length(ASource) + 1);
CharToOem(PChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;

procedure WritelnDos(ASource: String);
begin
Writeln(WinToDos(ASource));
end;
function DosToWin(ASource: AnsiString): AnsiString;
var
Ch: PAnsiChar;
begin
Ch := AnsiStrAlloc(Length(ASource) + 1);
OemToAnsi(PAnsiChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;

function DosToWin(ASource: AnsiString): String;
var
Ch: PChar;
begin
Ch := StrAlloc(Length(ASource) + 1);
OemToChar(PAnsiChar(ASource), Ch);
Result := StrPas(Ch);
StrDispose(Ch)
end;


function AsciiToAnsi(AsciiStr: string): string;
var AnsiStr: string;
begin
SetLength(AnsiStr, Length(AsciiStr));
if Length(AsciiStr) > 0 then OemToChar(PChar(AsciiStr), PChar(AnsiStr));
AsciiToAnsi:= AnsiStr;
end;

function AnsiToAscii(AnsiStr: string): string;
var AsciiStr: string;
begin
SetLength(AsciiStr, Length(AnsiStr));
if Length(AnsiStr) > 0 then CharToOem(PChar(AnsiStr), PChar(AsciiStr));
AnsiToAscii:= AsciiStr;
end;

沒有留言: