08-30-2018, 12:44 PM
(This post was last modified: 08-30-2018, 06:25 PM by rlebeau.
Edit Reason: fixing formatting
)
Excuse me, but this is not solved completely. #include <IdHeaderCoderPlain.hpp> works fine in test. But in main project it no action.
The problem was found by debugger trace into Indy sources. In IdHeaderCoderList.pas:
Indy selects a coder that will decode a header's string.
In my test application coders are loaded in order:
TIdHeaderCoderPlain
TIdHeaderCoderIndy
TIdHeaderCoder2022JP
The letter's headers encoded in KOI-8R.
So, when TIdHeaderCoderList.ByCharSet is called, first from end is TIdHeaderCoder2022JP. Its CanHandle returns "false" and next is TIdHeaderCoderIndy. Its CanHandle returns "true" and message decodes by TIdHeaderCoderIndy fine.
When I use this in my main project order of coders is other:
TIdHeaderCoderIndy
TIdHeaderCoder2022JP
TIdHeaderCoderPlain
First from end is TIdHeaderCoderPlain. It returns "true" and message is not decoded and unreadable. TIdHeaderCoderIndy not used.
What can I do?
Indy 10.2.6
The problem was found by debugger trace into Indy sources. In IdHeaderCoderList.pas:
Code:
function TIdHeaderCoderList.ByCharSet(const ACharSet: string): TIdHeaderCoderClass;
var
I: Integer;
LCoder: TIdHeaderCoderClass;
begin
Result := nil;
// loop backwards so that user-defined coders can override native coders
for I := Count-1 downto 0 do begin
LCoder := TIdHeaderCoderClass(Items[I]);
if LCoder.CanHandle(ACharSet) then begin
Result := LCoder;
Exit;
end;
end;
end;
Indy selects a coder that will decode a header's string.
In my test application coders are loaded in order:
TIdHeaderCoderPlain
TIdHeaderCoderIndy
TIdHeaderCoder2022JP
The letter's headers encoded in KOI-8R.
So, when TIdHeaderCoderList.ByCharSet is called, first from end is TIdHeaderCoder2022JP. Its CanHandle returns "false" and next is TIdHeaderCoderIndy. Its CanHandle returns "true" and message decodes by TIdHeaderCoderIndy fine.
When I use this in my main project order of coders is other:
TIdHeaderCoderIndy
TIdHeaderCoder2022JP
TIdHeaderCoderPlain
First from end is TIdHeaderCoderPlain. It returns "true" and message is not decoded and unreadable. TIdHeaderCoderIndy not used.
What can I do?
Indy 10.2.6