Einzelnen Beitrag anzeigen

moelski

Registriert seit: 31. Jul 2004
1.110 Beiträge
 
Delphi 2010 Professional
 
#8

Re: SNMP Trap senden mit Indy ?

  Alt 21. Sep 2009, 11:45
Moin !

Es liegt an dieser Funktion:
Delphi-Quellcode:
function ToBytes(const AValue: string; const ALength: Integer; const AIndex: Integer = 1;
  const AEncoding: TIdEncoding = en7Bit): TIdBytes; overload;
var
  LLength: Integer;
begin
  ValidEncoding(AEncoding);
  LLength := IndyLength(AValue, ALength, AIndex);
  if LLength > 0 then
  begin
    if AEncoding = enUTF8 then begin
      Result := StringToUTF8Bytes(AValue, AIndex, LLength);
    end else
    begin
      // do just a byte to byte copy with no translation. VCL uses ANSI or MBCS.
      // With MBCS we still map 1:1
      SetLength(Result, LLength);
      CopyTIdString(AValue, AIndex, Result, 0, LLength,AEncoding);
    end;
  end else begin
    SetLength(Result, 0);
  end;
end;
Zu finden in IdGlobal.

Dort wird es zu en7Bit codiert und da verliert das $A4 ein $80 und "mutiert" zum $24 ...

Nu is die Frage wie man diese Codierung vorher beeinflussen kann.

Aufgerufen wird das übrigens von:
Delphi-Quellcode:
function ToBytes(const AValue: string; const AEncoding: TIdEncoding = en7Bit): TIdBytes; overload;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
  Result := ToBytes(AValue, -1, 1, AEncoding);
end;
Und das wiederum von
Delphi-Quellcode:
procedure TIdUDPBase.Send(const AHost: string; const APort: TIdPort; const AData: string);
begin
  SendBuffer(AHost, APort, ToBytes(AData));
end;
Tja nu steht man(-n) im Wald. Das Indy Buch schweigt sich dazu auch ganz brilliant aus

Any idea ?
Dominik Schmidt
Greetz Dominik

I love Delphi 2007/2010
  Mit Zitat antworten Zitat