ColdFusion, ???????123123???? ???non-En...">

Can ColdFusion send events sent by the HTML5 server to utf-8?

using <cfcontent type="text/event-stream">ColdFusion, ???????123123???? ???non-English characters are displayed as question marks: but the rest of the page can display non-English characters in order.

I watched this parity and tried

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

and

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

Both of them do not work with Chrome (they do not pick it up, the developer tool reports "on hold" without reconnecting.

+3
source share
1 answer

Just tried the following code and it works fine (showing the correct characters in the Chrome console) ...

testHTML5ServerSent events

    <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>

sendServerSentEvents.cfm

    <cfcontent type="text/event-stream; charset=utf-8" >
data: Γ©ΓͺtititiΓ§Γ 
</cfcontent>
+1
source

All Articles