Paul wrote:
> It's mostly ascii characters, but sometimes, the string contains a few
> unicode characters which can have different code pages for each
> character. Since the ClientCnx.AnswerString is an AnsiString anyway,
> I think the only choise is to convert them to UTF8.
That's correct, however not possible with current THttpConnection.
A small change should do the trick (untested):
procedure AnswerString(var Flags : THttpGetFlag;
const Status : String;
const ContType : String;
const Header : String;
const Body : String
{$IFDEF COMPILER12_UP};
CodePage : Integer = CP_ACP
{$ENDIF});
procedure THttpConnection.AnswerString(
var Flags : THttpGetFlag;
const Status : String; { if empty, default to '200 OK' }
const ContType : String; { if empty, default to 'text/html' }
const Header : String; { Do not use Content-Length nor Content-Type }
const Body : String { Could be empty. No default. }
{$IFDEF COMPILER12_UP};
CodePage : Integer = CP_ACP
{$ENDIF});
begin
DocStream.Free;
DocStream := TStringStream.Create(Body{$IFDEF COMPILER12_UP},
CodePage{$ENDIF});
AnswerStream(Flags, Status, ContType, Header);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
Then call it with CodePage CP_UTF8 and ContType "Content-Type: text/html;
charset=utf-8"
Does it work?
--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be