I'm attempting to export international characters from query to csv. Output to the browser works fine, as does writing to Excel using CFSPREADSHEET.
I have the following set up:
- The datasource connection uses JDBC
- Table fields are nvarchar
Rendering the file is as follows:
<cfset filepath="c:/test.csv" />
<cfloop query="q">
<cfset string = "" />
<cfset string = listAppend(string, q.fieldname) />
<cffile action="append" file="#filePath#" output="#string#" charset="windows-1252" />
</cfloop>
<cffile action="readbinary" file="#filePath#" variable="bin" charset="windows-1252">
<cffile action="delete" file="#filePath#" />
<cfheader name="Content-Disposition" value="attachment; filename=Output.csv" charset="windows-1252">
<cfcontent type="text/plain" reset="true" variable="#bin#" />
However, certain characters are not converting properly. For example:
- Jørgen shows as Jørgen
- Sälzler shows as Sälzler
Update - Adding charset="windows-1252"
did solve a majority of the bad conversions including the above examples. The following still do not convert
- Krčobić shows Kr?obi?
- Mirosław shows Miro?aw
- Bożek shows Bo?ek