Localisation issues in Lazarus/FPC indy port

Giganews Newsgroups
Subject: Localisation issues in Lazarus/FPC indy port
Posted by:  hovercraft (…@csk.ru)
Date: Thu, 29 Jun 2006

Currently I'm porting to FPC/Lazarus/Indy an application intended for sending invoices via email to our company customers.
Using indy- for Lazarus.
Using Lazarus 0.9.17SVN
Using FPC 2.1.1SVN
Our clients would expect to see entire message in russian because we reside in this country.
But I've found my russian texts in the From, Subject and other fields looks unreadable for recepient, even if I set correct CharSet property to
TidMessage object.
Message header contains e.g. the following text:
From: =?ISO-8859-1?Q?=CA=EE=F0=EF=EE=F0=E0=F6=E8=FF =D1=E5=E2=E5=F0=ED=E0=FF
=?ISO-8859-1?Q?=CA=EE=F0=EE=ED=E0?= <…@csk.ru>

So the "From" field is unreadable due to incorrect code page ISO-8859-1.
I expect to see there the value, I've set in idMessage.CharSet.
Appear that my CharSet value was ignored. Look at IdMessage.pas and see the following code:

procedure TIdMessage.GenerateHeader;
  InitializeISO(TransferHeader, HeaderEncoding, ISOCharSet);
    Values['From'] := EncodeAddress(FromList, HeaderEncoding, TransferHeader, ISOCharSet, True); {do not localize}
procedure TIdMessage.InitializeISO(var VTransferHeader: TTransfer; var VHeaderEncoding: Char; var VCharSet: String);
  VCharSet := IdCharsetNames[IdGetDefaultCharSet];

{IdCharsetNames[IdGetDefaultCharSet] is alwais ISO-8859-1 on my FPC installation}

Questions are:
1. What does this "{do not localize}" mean? Actually the field appear localized, noting message header.
2. One can consider that problem arise from incorrect IdGetDefaultCharSet. But I cannot agree with it. In fact,
GenerateHeader should use CharSet property of TidMessage instead of IdCharsetNames[IdGetDefaultCharSet], if it is not empty.
Didn't it?
Imagine for example, we want to send message to person, whose language is different from our machine's locale settings.