Recent

Author Topic: [SOLVED] hotmail don't show utf8 email from lazarus  (Read 14287 times)

clauslack

  • Sr. Member
  • ****
  • Posts: 275
[SOLVED] hotmail don't show utf8 email from lazarus
« on: June 11, 2009, 03:19:11 pm »
Hi
I have a lazarus program that send email with indy, from a Tmemo

In gmail.com the email show fine, but in hotmail not.
Example:
name:='Señor';// (spanish sir)
                              hotmail.com     gmail.com             
Utf8                        Señor/a:         Señor/a:(Fine)   
Utf8toAnsi(name)   Se?or/a:     Se?or/a:   
Utf8toSys(name)          Se?or/a:             Se?or/a:   

with IdMessage.ContentTransferEncoding:='UTF8' hotmail show 'Señor/a:' too.

I use Lazarus 0.9.27 fpc 2.2.4 svn 20212 in Windows 2000 server sp4.

Any idea
Thanks




« Last Edit: June 11, 2009, 10:29:26 pm by clauslack »

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: hotmail.com don't show utf8 email from lazarus
« Reply #1 on: June 11, 2009, 05:04:04 pm »
Here is the problem
Gmail show fine Utf8, but Hotmail show iso8859-1.

But I can't send the email like iso8859-1

IdMessage.CharSet := 'csIso88591';// not work
and
UTF8ToISO_8859_1('Señor/a:') //not work

Thanks


« Last Edit: June 11, 2009, 07:12:08 pm by clauslack »

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: hotmail.com don't show utf8 email from lazarus
« Reply #2 on: June 11, 2009, 10:28:48 pm »
Now works fine, the email send to hotmail, show fine in windows and Linux (ISO8859-1)

The problem seems to be in TMemo
Code: [Select]
1) memo1.lines.add(UTF8ToISO_8859_1('Señor/a:'));
2) idmessage.Body.Text := memo1.lines.text;
3) idSMTP.send(idmessage);
This shows the wrong string in hotmail.

With a TStringList work fine.(copy memo to tstringlist)
Code: [Select]
1) for i:=0 to memo1.lines.count-1 do     
            lista.Add(UTF8ToISO_8859_1(memo1.lines[i]));
2) idmessage.Body.Text := lista.Text;
3) idSMTP.send(idmessage);
looks like a bug in TMemo, but I'm not sure.

Regards

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #3 on: June 12, 2009, 12:01:22 am »
Maybe the memo doesn't accept invalid UTF8.

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #4 on: June 12, 2009, 02:45:21 am »
Hi, look at this..
convert string through LCL's controls.
Code: [Select]
const cadenaUTF8='señor';
Code: [Select]
with memo1.lines do begin
clear;
add(cadenaUTF8);                   //show 'señor'
        add(UTF8ToISO_8859_1(cadenaUTF8));   //show 'se?or'
        SaveToFile('memo.log');                      //save utf8 'señor' and
end;                                          //save 'se?or'    -> wrong iso8859-1
Code: [Select]
with listbox1.items do begin
  clear;
  add(cadenaUTF8);         // show 'señor'
  add(UTF8ToISO_8859_1(cadenaUTF8));        //  show 'se'
  SaveToFile('listbox.log');          //save utf8 'señor' and
end;                //save 'se'    -> wrong
GrabaLog save a string to text file.
Code: [Select]
 edit1.text:=UTF8ToISO_8859_1(cadenaUTF8);     //show 'se'
  GrabaLog('edit1.text: '+edit1.text);       //save 'se'
  GrabaLog('UTF8ToISO_8859_1(cadenaUTF8): '+UTF8ToISO_8859_1(cadenaUTF8));  //save iso8859-1 'señor'
But button1 y label (caption) save fine iso8859-1
Code: [Select]
  label1.caption:=UTF8ToISO_8859_1(cadenaUTF8);   //show 'se'
   GrabaLog('label1.caption: '+label1.caption);     //save iso8859-1 'señor'

With Utf8ToAnsi happens too.
Conclusion:
Convert string UTF8toISO_8859_1 with TMemo, TListBox, TEdit not work well.
But work fine with TButton and TLabel.
Is the correct behavior?
Upload a example to test.
I use Lazarus 0.9.27 fpc 2.2.4 svn 20212 in Windows XP SP3

Regards.
« Last Edit: June 12, 2009, 02:48:34 am by clauslack »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #5 on: June 12, 2009, 11:04:27 am »
Lazarus controls handle only UTF-8.

If you do this:

edit1.text:=UTF8ToISO_8859_1(cadenaUTF8);     

The result is "undefined", because TEdit (and all other controls) do not handle ISO_8859_1 etc. correctly, only UTF-8.

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #6 on: June 12, 2009, 01:21:40 pm »
Yes, you right, but look that TStringList, TButton and TLabel works fine with non UTF8.(saving to file or sending an email, not for show in the form)

Anyway is a curiosity for share with all.

Regards

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #7 on: June 12, 2009, 02:34:25 pm »
Yes, but it's not a curiosity, it's simply "undefined". I may work or not. This is not a bug.
It probably depends on whether lazarus buffers the string in pascal code or uses the buffer of the widget.
Just always assume it's handling UTF-8 only and you're fine.

mbohn

  • Full Member
  • ***
  • Posts: 120
Re: [SOLVED] hotmail don't show utf8 email from lazarus
« Reply #8 on: April 29, 2010, 03:49:11 pm »
@Clauslack:

Can you post all your code that pertains to mailing to gmail with Indy?

Thanks.

clauslack

  • Sr. Member
  • ****
  • Posts: 275

 

TinyPortal © 2005-2018