Copy link to clipboard
Copied
I have a database full of the word "Café" and coldfusion will output the é fine on a webpage or using cfdump or simply cfoutput. However when I try and write to a txt file using cffile it replaces it with "?". (code below)
This also occcurs when I read a txt file and output the results using cffile. It is my opinion he cffile is the culprit here. Any thoughts on this?
<cfquery name="get_all" datasource="#dsn#">
select * from malls where fkmasterid=1
</cfquery>
<cfloop query="get_all">
<cfquery name="get_b" datasource="mbi_2">
SELECT lt_ben_cat.benefit_cat, benefits.name, benefits.link, benefits.address_line1, benefits.phone, benefits.restaurant_number, benefits.county, benefits.city, benefits.state, benefits.ZIP, benefits.valid
FROM benefits INNER JOIN
lt_ben_cat ON benefits.benefit_type = lt_ben_cat.initial
WHERE benefits.website_pull LIKE '%#accesskey#%' ORDER BY lt_ben_cat.benefit_cat, benefits.name
</cfquery>
<cfsavecontent variable="myvar">
<cfoutput>Type#chr(9)#Name#chr(9)#Website#chr(9)#Address#chr(9)#Phone#chr(9)#MemberCard#chr(35)##chr(9)#Region#chr(9)#City#chr(9)#State#chr(9)#Zip Code#chr(9)#Valid</cfoutput>
<cfloop query="get_b">
<cfoutput>#get_b.benefit_cat##chr(9)##get_b.name##chr(9)##get_b.link##chr(9)##get_b.address_line1##chr(9)##get_b.phone##chr(9)##get_b.restaurant_number##chr(9)##get_b.county##chr(9)##get_b.city##chr(9)##get_b.state##chr(9)##get_b.ZIP##chr(9)##get_b.valid#</cfoutput>
</cfloop>
</cfsavecontent>
<cffile action="write" file="/home/membercard/#get_all.malldir#/benefit_list.txt" output="#myvar#">
</cfloop>
When I try and import it
Thanks Joshua. You got me in the ballpark on that one. I used the charset="iso-8859-1" and that gave me the "é" but now I see there is "?" for the character "☼"
I may have to do a replace on that one. I have no idea what character set supports that symbol.
Copy link to clipboard
Copied
When you see an issue like that it is usually that diferent parts of the
system are not of the same characterset. Most likely the db is UTF-8 and
the file written is latin-1 or something like that.
Try in your CFfile to specify charset="utf-8".
Copy link to clipboard
Copied
Thanks Joshua. You got me in the ballpark on that one. I used the charset="iso-8859-1" and that gave me the "é" but now I see there is "?" for the character "☼"
I may have to do a replace on that one. I have no idea what character set supports that symbol.
Copy link to clipboard
Copied
If you can find out what char set the db is, that should put you right.
Also your html may specify a charset at the top of the page, and that
should help as well as they seem to appear correctly on the page.
Copy link to clipboard
Copied
I used a replace to handle the "☼" character and replaced it with "¤" (close enough for me)
Thanks for your help Joshua
Find more inspiration, events, and resources on the new Adobe Community
Explore Now