Solved

Special Character in CFImage text

Posted on 2011-02-28
11
549 Views
Last Modified: 2012-05-11
Hi all,

I'm trying to render some text (£10.00) to an image using cfimage. However I can't get the £ character to render correctly, I just get £10.00 (see attached image).

I'm using the following code to generate the image. Any help with this would be greatly appreciated.

<cfset voucherValue = "£10.00">

<!--- Create new blank image --->
<cfset newCodeImage = ImageNew("", 450, 140, "rgb", "##FFFFFF") />

<!--- Set new text attributes. --->
<cfset attr = StructNew()>
<cfset attr.font="Arial">
<cfset attr.style="bold">
<cfset attr.size=110>
<cfset ImageSetDrawingColor(newCodeImage,"##000000")>
<cfset ImageSetAntialiasing(newCodeImage)>

<!--- Add value to blank image --->
<cfset ImageDrawText(newCodeImage,"#voucherValue#",0,115,attr)>

<!--- Save temp image --->
<cfimage action="writeToBrowser" source="#newCodeImage#">

Open in new window


 cfimage_specChar
0
Comment
Question by:richard-mckenna
  • 6
  • 4
11 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 35002302
Try using the unicode representation of £
<cfset vourcherValue = "\U00A310.00">
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35002328
0
 

Author Comment

by:richard-mckenna
ID: 35002329
Unfortunatly not that just renders

\U00A310.00
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 200 total points
ID: 35002344
What version of CF are you running. It outputs fine for me w/CF9.0.1
0
 

Author Comment

by:richard-mckenna
ID: 35002366
Ah 9,0,0,251028 let me try updating CF. Good thinking there :)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 52

Expert Comment

by:_agx_
ID: 35002390
Try adding a UTF8 directive explicitly first. Might be the problem.

<cfprocessingdirective pageencoding="utf-8">
0
 
LVL 3

Accepted Solution

by:
sajayc earned 300 total points
ID: 35002454
Hi,
Try using the ascii chr code for the pound sign.

<cfset vourcherValue = chr(153) & "10.00">

Hope this helps.

0
 

Author Comment

by:richard-mckenna
ID: 35002492
Solved thanks guys, youve been a great help.

cfprocessingdirective didn't do anything.

After the 9.0.1 update <cfset voucherValue = "£10.00"> renders correctly.

<cfset vourcherValue = chr(163) & "10.00"> works as well (note the number is 163) and I think I'm gonna go with this as it seems a bit more complete.

Thanks again.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35002530
cfprocessingdirective didn't do anything
Not sure why. A literal copy and pasted worked perfectly for me. But if the ascii code works, then it's definitely an encoding problem.  
0
 

Author Comment

by:richard-mckenna
ID: 35002589
Yeah, they also must have changed the encoding in the 9.0.1 update. Think I'll have a look at the release notes when i get chance, see if I can find anything.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35002654
Hmm.. I just tested it again and it's not UTF8 that worked. It was windows-1252

<cfprocessingdirective pageEncoding="windows-1252">
<cfset voucherValue = "£10.00">
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now