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

心不动则不痛 提交于 2019-12-10 19:39:35

问题


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


回答1:


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

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.



来源:https://stackoverflow.com/questions/39709490/why-are-certain-characters-not-being-injected-correctly-to-sql-server-from-a-cfq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!