0
我有一個德爾福柏林的程序,我想轉換爲Linux作爲控制檯應用程序。下面是我的程序:Delphi東京HexToBin Linux版
StrVal is declare as Private
procedure DoGetSy();
var
s: String;
n: Integer;
HasSy: Boolean;
begin
HasSy := False;
if ch = '_' then begin
SyBegPos := ix-1;
sy := StrCharSetSy;
GetChar();
GetIdent();
Ident := '_' + Ident;
HasSy := True;
end;
if (not HasSy) and (IBServerOptions.SQLServerVersion in [st_Firebird_25, st_Firebird_30]) then begin
if (ch = '0') and ((CurCh()='x') or (CurCh()='X')) then begin
// hex literal (integer)
sy := IntValSy;
GetChar();
GetChar();
StrVal := '';
while CharInSet(ch, ['0'..'9','A'..'F','a'..'f']) do begin
StrVal := StrVal + ch;
GetChar();
end;
// (?) Int64
// IntVal := StrToInt('$' + StrVal);
IntVal := 0;
if TryStrToInt(StrVal, n) then begin
IntVal := n;
end;
HasSy := True;
end
else if ((UpCase(ch) = 'X') and (CurCh() = '''')) then begin
// hex literal (binary string)
GetChar();
sy := StrValSy;
StrQuoteCh := ch;
StrVal := GetStr();
n := Length(StrVal);
if (Odd(n)) then n := (n div 2) + 1
else n := n div 2;
StrVal := LowerCase(StrVal);
SetLength(s, n);
HexToBin(PChar(StrVal), PChar(s), n);// in Linux here compiler gives exception as There is no overloaded version of 'HexToBin' that can be called with these arguments
StrVal := s;
HasSy := True;
end;
end; // Firebird 2.5, 3.0
if not HasSy then begin
inherited;
if (sy = StrValSy) and (StrQuoteCh = '"') and
(IBServerOptions.SQLDialect = 3) and (StrVal <> '') then begin
sy := IdentSy;
Ident := StrVal;
end;
end;
end;
在Linux下它使用下面的方法:
procedure BinToHex(const Buffer: TBytes; BufOffset: Integer;
var Text: TBytes; TextOffset: Integer; Count: Integer); overload;
,其中在Windows上,它完美地工作。我怎樣才能克服這一點?
如果你看看源代碼(System.Classes),你會發現BinToHex和HexToBin函數只有'$ IFNDEF NEXTGEN'可用,我很確定(雖然我可能是錯的 - 我已經由於我目前不需要Linux支持,所以沒有多加註意)Linux編譯器是NEXTGEN,所以這些函數將不可用。 Windows編譯器不是NEXTGEN,所以函數在那裏可用。 –
是的,Linux編譯器是一個NEXTGEN編譯器 –
相關:[如何在Android的Delphi Firemonkey中使用HextoBin](http://stackoverflow.com/questions/42962063/)。 –