?
Solved

LSEuroCurrencyFormat & CFFile problem

Posted on 2003-02-28
9
Medium Priority
?
349 Views
Last Modified: 2013-12-24
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
Comment
Question by:JimV_ATL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 2

Expert Comment

by:weeezl
ID: 8043048
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
 
LVL 5

Author Comment

by:JimV_ATL
ID: 8043083
Thanks for your suggestion!

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

Jim
0
 
LVL 5

Author Comment

by:JimV_ATL
ID: 8043114
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 5

Author Comment

by:JimV_ATL
ID: 8043141
Hmmm...looks like EE must have escaped the Euro symbol in the above.  
0
 
LVL 2

Expert Comment

by:weeezl
ID: 8043234
0
 
LVL 5

Author Comment

by:JimV_ATL
ID: 8043731
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
 
LVL 5

Author Comment

by:JimV_ATL
ID: 8044368
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
 
LVL 5

Author Comment

by:JimV_ATL
ID: 8044389
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8044755
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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 6 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question