richard-mckenna
asked on
Special Character in CFImage text
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.
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#">
ie "\U00A3" instead of "£"
http://www.fileformat.info/info/unicode/char/a3/index.htm
http://www.fileformat.info/info/unicode/char/a3/index.htm
ASKER
Unfortunatly not that just renders
\U00A310.00
\U00A310.00
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah 9,0,0,251028 let me try updating CF. Good thinking there :)
Try adding a UTF8 directive explicitly first. Might be the problem.
<cfprocessingdirective pageencoding="utf-8">
<cfprocessingdirective pageencoding="utf-8">
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
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.
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.
ASKER
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.
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">
<cfprocessingdirective pageEncoding="windows-1252
<cfset voucherValue = "£10.00">
<cfset vourcherValue = "\U00A310.00">