Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-02-2014
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.488
Poder: 20
MAXIUM Va camino a la fama
Error con asunto al usar Indy =?UTF-8?

Hola, Al leer el asunto de un correo, en algunos mensajes me sale por ejemplo: =?utf-8?Q?AW:_Neues_Projekt_Sch=C3=BCrn_Warenwirtschaft_ ?=

Uso DElphi 7 e Indy 10

Gracias
Responder Con Cita
  #2  
Antiguo 20-02-2014
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.488
Poder: 20
MAXIUM Va camino a la fama
Solución:

Código Delphi [-]
Uses 
    IdCoderQuotedPrintable, StrUtils;

function DeleteUTF8ControlStrings(Text: String): String;
var
  Encoded       : String;
  Dump          : String;
  StartPos      : Integer;
  EndPos        : Integer;
begin
  Encoded:='';
  Dump:=Text;
  while Pos('=?UTF-8',AnsiUpperCase(Dump))<>0 do
  begin
    StartPos:=Pos('=?UTF-8',AnsiUpperCase(Dump))+10;
    EndPos:=Pos('?=',AnsiUpperCase(Dump));
    Encoded:=Encoded+Copy(Dump,StartPos,EndPos-StartPos);
    Dump:=Encoded+Copy(Dump,EndPos+3,Length(Dump)-(EndPos+2));
  end;
  Result:=Trim(AnsiReplaceStr(Encoded,'_',' '));
end;

function MailsGetSubject(Subject: String): String;
var
  Decoder        : TIdDecoderQuotedPrintable;
  TextAnsi       : String;
begin
  Result:=Subject;
  if Pos('=?UTF-8',Subject)<>0 then
  begin
    Decoder:=TIdDecoderQuotedPrintable.Create;
    try
      Result:=DeleteUTF8ControlStrings(Subject);
      Result:=Decoder.DecodeString(Result);
      TextAnsi:=UTF8ToAnsi(Result);
      if Length(TextAnsi)>0 then Result:=TextAnsi;
    finally
      FreeAndNil(Decoder);
    end;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
Var
    Asunto: String;
Begin
       ...
       ...
       ...
       Asunto:= MailsGetSubject(IdMessage1.Subject);
       ...
       ...
       ...
End;
Responder Con Cita
  #3  
Antiguo 20-02-2014
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.042
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Puedo usar las Indy con Kylix? DarkByte Lazarus, FreePascal, Kylix, etc. 3 15-05-2004 19:09:50
Asunto de cookies y sesiones gatsu PHP 3 26-04-2004 18:55:24
Asunto Unidad CD-ROM wpolanco Varios 1 16-09-2003 23:05:37
nuevo asunto sobre un TreeView? judoboy OOP 4 24-07-2003 17:23:51
asunto solucionado... superhopi Impresión 4 16-05-2003 11:00:58


La franja horaria es GMT +2. Ahora son las 15:15:58.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi