Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How I can decode TIdMessage from koi8-r to windows-1251?
#3
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:

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
Reply


Messages In This Thread
RE: How I can decode TIdMessage from koi8-r to windows-1251? - by SergJP - 08-30-2018, 12:44 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)