Search code examples
sql-servercoldfusioncfmllucee

Why are certain characters not being injected correctly to SQL Server from a CFQUERY?


I have a Coldfusion app running on Lucee which connects to a SQL Server database.

When I run the following query directly in SQL Server Manager:

UPDATE article
SET content='20m²'
WHERE id=3159

The column gets populated fine with 20m².

HOWEVER, when run from a cfml page which simply runs this:

UPDATE article SET content='20m²' WHERE id=3159

The column gets populated with: 20m²

As in, this additional  character appears. This also occurs with some other special characters, but most are fine. Is this to do with some configuration of the jdbc connector? I don't see what the difference should be between the above two? Putting the value in a cfqueryparam tag makes no difference.

Thanks


Solution

  • If it's hard coded, I believe you'll want to make sure you save that file in Unicode UTF-8.

    enter image description here

    Also make sure your JVM arguments will process that as well. Admin > Server Settings > Java and JVM. Add " -Dfile.encoding=UTF-8" to the Arguments.

    enter image description here