JimV_ATL
asked on
LSEuroCurrencyFormat & CFFile problem
LSEuroCurrencyFormat appears to work perfectly for me when during typical conditions when I display the results using <cfoutput>. However, when I write the results to a file using CFFile, it displays a "? " instead of the expected Euro Symbol.
Note the following:
1) I'm using CFMX. I have run both updaters.
2) LSCurrencyFormat works fine both when outputed using CFOutput as well as using CFFile.
Here is sample code which reproduces my error:
<!--- You'll want to change this for your environment --->
<cfset absolute_file_root = "c:\webs\sandbox\">
<cfsavecontent variable="results">
<cfoutput>
<table>
<cfloop index="idx" list="English (UK),English (US),Dutch (Standard),French (Standard),German (Standard),Italian (Standard)">
<cfset temp = setlocale(idx)>
<tr><td>#idx#</td><td>#LSE uroCurrenc yFormat(10 00.00)#</t d><td>#LSC urrencyFor mat(1000.0 0)#</td></ tr>
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<!--- Results display as expected here. --->
<cfoutput>
#results#
</cfoutput>
<!--- Next two lines create unique file name --->
<cfset timestamp = DateFormat(now(),"yyyymmdd ") & TimeFormat(now(),"HHmmss") >
<cfset filename= "test_" & timestamp & ".htm">
<!--- Results don't display as expected here. --->
<cffile action="WRITE" file="#absolute_file_root# Temp\#file name#" output="#results#" addnewline="No">
Note the following:
1) I'm using CFMX. I have run both updaters.
2) LSCurrencyFormat works fine both when outputed using CFOutput as well as using CFFile.
Here is sample code which reproduces my error:
<!--- You'll want to change this for your environment --->
<cfset absolute_file_root = "c:\webs\sandbox\">
<cfsavecontent variable="results">
<cfoutput>
<table>
<cfloop index="idx" list="English (UK),English (US),Dutch (Standard),French (Standard),German (Standard),Italian (Standard)">
<cfset temp = setlocale(idx)>
<tr><td>#idx#</td><td>#LSE
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<!--- Results display as expected here. --->
<cfoutput>
#results#
</cfoutput>
<!--- Next two lines create unique file name --->
<cfset timestamp = DateFormat(now(),"yyyymmdd
<cfset filename= "test_" & timestamp & ".htm">
<!--- Results don't display as expected here. --->
<cffile action="WRITE" file="#absolute_file_root#
ASKER
Thanks for your suggestion!
I'm hoping for more of a direct solution rather than a work-around.
Jim
I'm hoping for more of a direct solution rather than a work-around.
Jim
ASKER
One more comment:
When I view the output from the CFOutput it looks like:
<table>
<tr><td>English (UK)</td><td>£1,000.00</td ><td>£1,00 0.00</td>< /tr>
<tr><td>English (US)</td><td>$1,000.00</td ><td>$1,00 0.00</td>< /tr>
<tr><td>Dutch (Standard)</td><td>€ 1.000,00</td><td>fl 1.000,00</td></tr>
<tr><td>French (Standard)</td><td>1 000,0 0 €</td><td>1 000,00 F</td></tr>
<tr><td>German (Standard)</td><td>1.000,0 0 €</td><td>1.000,00 DM</td></tr>
<tr><td>Italian (Standard)</td><td>€ 1.000,00</td><td>L. 1.000</td></tr>
</table>
When I view the output from the CFFile it looks like:
<table>
<tr><td>English (UK)</td><td>£1,000.00</td ><td>£1,00 0.00</td>< /tr>
<tr><td>English (US)</td><td>$1,000.00</td ><td>$1,00 0.00</td>< /tr>
<tr><td>Dutch (Standard)</td><td>? 1.000,00</td><td>fl 1.000,00</td></tr>
<tr><td>French (Standard)</td><td>1 000,0 0 ?</td><td>1 000,00 F</td></tr>
<tr><td>German (Standard)</td><td>1.000,0 0 ?</td><td>1.000,00 DM</td></tr>
<tr><td>Italian (Standard)</td><td>? 1.000,00</td><td>L. 1.000</td></tr>
</table>
When I view the output from the CFOutput it looks like:
<table>
<tr><td>English (UK)</td><td>£1,000.00</td
<tr><td>English (US)</td><td>$1,000.00</td
<tr><td>Dutch (Standard)</td><td>€ 1.000,00</td><td>fl 1.000,00</td></tr>
<tr><td>French (Standard)</td><td>1 000,0
<tr><td>German (Standard)</td><td>1.000,0
<tr><td>Italian (Standard)</td><td>€ 1.000,00</td><td>L. 1.000</td></tr>
</table>
When I view the output from the CFFile it looks like:
<table>
<tr><td>English (UK)</td><td>£1,000.00</td
<tr><td>English (US)</td><td>$1,000.00</td
<tr><td>Dutch (Standard)</td><td>? 1.000,00</td><td>fl 1.000,00</td></tr>
<tr><td>French (Standard)</td><td>1 000,0
<tr><td>German (Standard)</td><td>1.000,0
<tr><td>Italian (Standard)</td><td>? 1.000,00</td><td>L. 1.000</td></tr>
</table>
ASKER
Hmmm...looks like EE must have escaped the Euro symbol in the above.
See this post:
http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=3&threadid=260519&highlight_key=y&keyword1=LSEuroCurrencyFormat
Need to implement a workaround for now...
http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=3&threadid=260519&highlight_key=y&keyword1=LSEuroCurrencyFormat
Need to implement a workaround for now...
ASKER
The article is over a year old and refers to different symptoms on CF5. The common denominator seems to be that LSEuroCurrencyFormat is not among the better tested CF functions, so it is easy for me to believe that this is a bug and requires a work-around.
Thanks for the link! If I don't get the answer I'm looking for by Monday morning, then the points are yours.
Thanks for the link! If I don't get the answer I'm looking for by Monday morning, then the points are yours.
ASKER
I got the solution I was looking for.
1) Added <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> to the <head> portion of the html output. (Actually, I had to make the entire output valid html, prior to that point it was just the table code.)
2) Explicitly added charset="UTF-8" to the cffile.
Here is the resulting code that worked:
<!--- You'll want to change this for your environment --->
<cfset absolute_file_root = "c:\webs\sandbox\">
<cfsavecontent variable="results">
<cfoutput>
<table>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<cfloop index="idx" list="English (UK),English (US),Dutch (Standard),French (Standard),German (Standard),Italian (Standard)">
<cfset temp = setlocale(idx)>
<tr><td>#idx#</td><td>#LSE uroCurrenc yFormat(10 00.00)#</t d><td>#LSC urrencyFor mat(1000.0 0)#</td></ tr>
</cfloop>
</body>
</html>
</table>
</cfoutput>
</cfsavecontent>
<!--- Results display as expected here. --->
<cfoutput>
#results#
</cfoutput>
<!--- Next two lines create unique file name --->
<cfset timestamp = DateFormat(now(),"yyyymmdd ") & TimeFormat(now(),"HHmmss") >
<cfset filename= "test_" & timestamp & ".htm">
<!--- Results don't display as expected here. --->
<cffile action="WRITE" file="#absolute_file_root# Temp\#file name#" output="#results#" addnewline="No" charset="UTF-8">
1) Added <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> to the <head> portion of the html output. (Actually, I had to make the entire output valid html, prior to that point it was just the table code.)
2) Explicitly added charset="UTF-8" to the cffile.
Here is the resulting code that worked:
<!--- You'll want to change this for your environment --->
<cfset absolute_file_root = "c:\webs\sandbox\">
<cfsavecontent variable="results">
<cfoutput>
<table>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<cfloop index="idx" list="English (UK),English (US),Dutch (Standard),French (Standard),German (Standard),Italian (Standard)">
<cfset temp = setlocale(idx)>
<tr><td>#idx#</td><td>#LSE
</cfloop>
</body>
</html>
</table>
</cfoutput>
</cfsavecontent>
<!--- Results display as expected here. --->
<cfoutput>
#results#
</cfoutput>
<!--- Next two lines create unique file name --->
<cfset timestamp = DateFormat(now(),"yyyymmdd
<cfset filename= "test_" & timestamp & ".htm">
<!--- Results don't display as expected here. --->
<cffile action="WRITE" file="#absolute_file_root#
ASKER
I'm going ask that my answer be the answer to this question (for Knowledge Base purposes). I've opened a second question, so you can have the ponits.
https://www.experts-exchange.com/questions/20534110/Points-for-weeezl.html
https://www.experts-exchange.com/questions/20534110/Points-for-weeezl.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I fixed it by doing a replace and writing the proper HTML.
<cfset absolute_file_root = "c:\webs\sandbox\">
<cfsavecontent variable="results">
<cfoutput>
<table>
<cfloop index="idx" list="English (UK),English (US),Dutch (Standard),French (Standard),German (Standard),Italian (Standard)">
<cfset temp = setlocale(idx)>
<tr><td>#idx#</td><td>#LSE
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<!--- Replace Euro Symbol with HTML --->
<cfset results=replace(results,'€
<!--- Results display as expected here. --->
<cfoutput>
#results#
</cfoutput>
<!--- Next two lines create unique file name --->
<cfset timestamp = DateFormat(now(),"yyyymmdd
<cfset filename= "test_" & timestamp & ".htm">
<!--- Results don't display as expected here. --->
<cffile action="WRITE" file="#absolute_file_root#