Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cfsavecontent + cfinclude with utf-8 charset?

I have a line of coldfusion code that includes an cfm file encoded with the utf-8 charset and saves it to a variable. The problem I am having is that there is no way to specify a charset in cfinclude and the resulting variable does not seem to be reading utf-8 correctly so any non ascii characters are rendered incorrectly.

<cfsavecontent variable="content">
  <cfinclude template="test.cfm">
</cfsavecontent>
<cfoutput>#content#</cfoutput>

If I use cffile this is not a problem because I can specify a chaset, but the file is not parsed for coldfusion variables.

<cfset path = expandPath(".") & "\test.html">
<cffile action="read" file="#path#" variable="content" charset="utf-8">
<cfoutput>#content#</cfoutput>

So my question - Is there a way to load a parsed coldfusion file into a variable while honoring a specific charset?

like image 357
Nick Van Brunt Avatar asked Jan 21 '23 05:01

Nick Van Brunt


1 Answers

I don't know if this will work or not, but the only thing I can think of is to put a

<cfprocessingdirective pageencoding="utf-8" />

tag at the very top of the code being included (test.cfm). This instructs CF to use a specific encoding when compiling the code.

like image 152
Edward M Smith Avatar answered Jan 28 '23 04:01

Edward M Smith