gpt4 book ai didi

html - ColdFusion 可以在 utf-8 中发送 HTML5 服务器发送的事件吗?

转载 作者:可可西里 更新时间:2023-11-01 14:57:53 24 4
gpt4 key购买 nike

使用 <cfcontent type="text/event-stream">在 ColdFusion 中,非英文字符显示为问号:???????123123???? ??? , 但页面的其余部分可以正常显示非英文字符。

我关注了this tutuorial并尝试过

<cfheader name="Content-Type" value="text/event-stream; charset=utf-8">

还有

<cfcontent type="text/event-stream; charset=utf-8">

它们都不能与 Chrome 一起使用(无法启动,开发者工具报告“待定”且没有重新连接。

最佳答案

刚刚尝试了以下代码,它运行良好(在 Chrome 的控制台中显示了正确的字符)...

testHTML5ServerSent 事件

    <HTML>

<HEAD>
<script language="javascript">
if (!!window.EventSource) {
var source = new EventSource('sendServerSentEvents.cfm');
source.addEventListener('message', function(e) {
console.log(e.data);
}, false);

source.addEventListener('open', function(e) {
// Connection was opened.
}, false);

source.addEventListener('error', function(e) {
if (e.eventPhase == EventSource.CLOSED) {
// Connection was closed.
}
}, false);

} else {
alert('not supported');// Result to xhr polling :(
}


</script>
</HEAD>

<BODY>

</BODY>

</HTML>

发送服务器发送事件.cfm

    <cfcontent type="text/event-stream; charset=utf-8" >
data: éêtititiçà
</cfcontent>

关于html - ColdFusion 可以在 utf-8 中发送 HTML5 服务器发送的事件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5263192/

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