gpt4 book ai didi

delphi - 从TWebRequest的内容字段读取unicode字符串

转载 作者:行者123 更新时间:2023-12-03 19:44:02 25 4
gpt4 key购买 nike

我们如何从TWebRequest的内容字段中检索实际的unicode字符串。当我尝试读取TWebRequest的内容字段以获取输入的unicode值时,我在文本中输入了内容,但看到的是加扰值,而不是实际值。
我输入的是Добро,但在内容字段中看到的是值“Добро¾。 Response内容类型设置为text / html和charset ='UTF-8'。
任何人都可以告诉我为什么它不显示在文本框中输入的实际值以及如何更正该值。

我正在测试的示例代码

procedure TWebModule1.WebModule1HelloAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
s : string;
PageProducer1 : TPageProducer;
begin
Response.ContentType := 'text/html;charset=UTF-8';
s := Request.ContentFields.Text;
PageProducer1 := TPageProducer.Create(nil);
try
PageProducer1.HTMLFile := 'C:\Hello.tmpl';
PageProducer1.OnHTMLTag := PageProducer1HTMLTag;
Response.Content := PageProducer1.Content + ' ' + 'Entered string:' + s;
finally
PageProducer1.Free;
end;
end;


Hello.tmpl只有文本框和提交按钮

最佳答案

您可以使用UTF8ToString函数将您的UTF-8字符串转换为UnicodeString

关于delphi - 从TWebRequest的内容字段读取unicode字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8941233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com