Search code examples
sqlsql-serverutf-8coldfusioniso-8859-1

Issue with cfquery text encoding


I have an encoding problem with the cfquery tag.

This is my code:

<cfquery name="query" datasource="example">
    SELECT *
    FROM EXAMPLE_TABLE
    WHERE EXAMPLE_COLUMN = 'WORD WITH ACCENT É'
</cfquery>

When doing a cfdump on the query variable, the generated sql by the cfquery tag changes the text to 'WORD WITH ACCENT É' but I need it to be É because the value in the table is set that way. Is there any way to change the encoding of the cfquery tag?

I tried changing the encoding of the page with the cfcontent tag to no avail. I also tried to use SetLocale() without much result either.

Thanks.


Solution

  • I found a solution.

    <cfprocessingdirective pageEncoding="UTF-8" />
    

    Added this at the top of the page and it works like a charm.