• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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>#LSEuroCurrencyFormat(1000.00)#</td><td>#LSCurrencyFormat(1000.00)#</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\#filename#" output="#results#" addnewline="No">


0
JimV_ATL
Asked:
JimV_ATL
  • 6
  • 2
1 Solution
 
weeezlCommented:
It seems like CF is writing the actual character to screen instead of using the HTML equivalent. This seems to be what is causing the problem on the write.

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>#LSEuroCurrencyFormat(1000.00)#</td><td>#LSCurrencyFormat(1000.00)#</td></tr>
</cfloop>
</table>
</cfoutput>
</cfsavecontent>

<!--- Replace Euro Symbol with HTML --->
<cfset results=replace(results,'€','&##8364;','all')>

<!---  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\#filename#" output="#results#" addnewline="No">
0
 
JimV_ATLAuthor Commented:
Thanks for your suggestion!

I'm hoping for more of a direct solution rather than a work-around.

Jim
0
 
JimV_ATLAuthor Commented:
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,000.00</td></tr>
<tr><td>English (US)</td><td>$1,000.00</td><td>$1,000.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,00 €</td><td>1 000,00 F</td></tr>
<tr><td>German (Standard)</td><td>1.000,00 €</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,000.00</td></tr>
<tr><td>English (US)</td><td>$1,000.00</td><td>$1,000.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,00 ?</td><td>1 000,00 F</td></tr>
<tr><td>German (Standard)</td><td>1.000,00 ?</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>

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
JimV_ATLAuthor Commented:
Hmmm...looks like EE must have escaped the Euro symbol in the above.  
0
 
JimV_ATLAuthor Commented:
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.

0
 
JimV_ATLAuthor Commented:
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>#LSEuroCurrencyFormat(1000.00)#</td><td>#LSCurrencyFormat(1000.00)#</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\#filename#" output="#results#" addnewline="No" charset="UTF-8">
0
 
JimV_ATLAuthor Commented:
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.

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_20534110.html
0
 
SpideyModCommented:
PAQ'd and points refunded.  The correct answer is in the post:
From: JimV_ATL  Date: 02/28/2003 12:27PM PST

SpideyMod
Community Support Moderator @Experts Exchange


JimV_ATL,
This is not the preferred method of handling cases like this.  The preferred method if you wanted to hand out points for effort would be to post you answer like you have, ask community support to reduce the value of the question to the amount of points you wish to give out, accept that answer, but post a comment on the end indicating what the correct answer you used was and you are giving our points for effort and accept the answer from the expert you want to give points to.  I cannot assign the answer to your own question to you, so the PAQ searcher is going to have to find the answer this way anyhow.  The reason why we prefer to do it this way is because the question will still have purchasing value at a lesser value.  As it stands now, this PAQ will be viewable for free by all.  I appreciate you wanting the correct answer to be in the PAQ, we just can't do it your proposed way
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now