【发布时间】:2023-03-14 05:49:01
【问题描述】:
我想在 delphi 7 上使用 indy 9.00.10 发送表情符号。我使用 tnt VCL Controls 。 我找到了这个 url http://apps.timwhitlock.info/emoji/tables/unicode 用于 unicode 和 bytes 代码。 如何将此代码转换为使用 indy 发送的 delphi 常量。
我使用这个 delphi 代码向电报机器人发送消息:
procedure TBotThread.SendMessage(ChatID:String; Text : WideString;
parse_mode:string;disable_notification:boolean);
Var
Stream: TStringStream;
Params: TIdMultipartFormDataStream;
//Text : WideString;
msg : WideString;
Src : string;
LHandler: TIdSSLIOHandlerSocket;
begin
try
try
if FShowBotLink then
Text := Text + LineBreak + FBotUser;
msg := '/sendmessage';
Stream := TStringStream.Create('');
Params := TIdMultipartFormDataStream.Create;
Params.AddFormField('chat_id',ChatID);
if parse_mode <> '' then
Params.AddFormField('parse_mode',parse_mode);
if disable_notification then
Params.AddFormField('disable_notification','true')
else
Params.AddFormField('disable_notification','false');
Params.AddFormField('disable_web_page_preview','true');
Params.AddFormField('text',UTF8Encode(Text));
LHandler := TIdSSLIOHandlerSocket.Create(nil);
FidHttpSend.ReadTimeout := 30000;
FidHttpSend.IOHandler:=LHandler;
LHandler.SSLOptions.Method := sslvTLSv1;
LHandler.SSLOptions.Mode := sslmUnassigned;
FidHttpSend.HandleRedirects := true;
FidHttpSend.Post(BaseUrl + API + msg, Params, Stream);
finally
Params.Free;
Stream.Free;
ENd;
except
on E: EIdHTTPProtocolException do
begin
if E.ReplyErrorCode = 403 then
begin
WriteToLog('Bot was blocked by the user');
end;
end;
end;
end;
表情符号的字节样本:
AERIAL_TRAMWAY = '\xf0\x9f\x9a\xa1';
AIRPLANE = '\xe2\x9c\x88';
ALARM_CLOCK = '\xe2\x8f\xb0';
ALIEN_MONSTER = '\xf0\x9f\x91\xbe';
抱歉英语不好!!!
【问题讨论】:
-
Indy 9 不支持 Unicode。您应该升级到 Indy 10。如果这不是一个选项,我将不得不深入研究 Indy 9 的代码,以便为您提供其他选项。无论哪种方式,您实际发布到哪个 URL?发布 Unicode 输入有什么要求?
-
感谢雷米的评论。我更改此行以发送电话表情符号。 Params.AddFormField('text',UTF8Encode(Text + LineBreak + #$0000260E ));这对我有用,但此代码不起作用:#$1F601 表示“笑脸笑脸”表情符号。我发布到电报机器人 API:api.telegram.org/bot。表情符号是unicode吗? .抱歉英语不好。
-
如何将emoji代码示例U+1F601转换并在delphi中使用?
标签: delphi unicode delphi-7 emoji indy-9